veryfront 0.1.200 → 0.1.201

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,6 +6,7 @@ type SafeParseResult<T> = {
6
6
  success: false;
7
7
  error: z.ZodError;
8
8
  };
9
+ import { type CommandResult } from "../../../src/platform/compat/process.js";
9
10
  import { type ApiClient } from "../../shared/config.js";
10
11
  import type { ParsedArgs } from "../../shared/types.js";
11
12
  import { type Logger } from "../../../src/utils/index.js";
@@ -89,6 +90,18 @@ export declare function runKnowledgeParser(input: {
89
90
  sourceReference?: string;
90
91
  env?: Record<string, string>;
91
92
  }): Promise<KnowledgeParserResult>;
93
+ export declare function executeKnowledgeParserCommand(input: {
94
+ scriptPath: string;
95
+ inputJsonPath: string;
96
+ outputJsonPath: string;
97
+ env?: Record<string, string>;
98
+ }, deps?: {
99
+ runCommandFn?: (cmd: string, options: {
100
+ args: string[];
101
+ env?: Record<string, string>;
102
+ capture: true;
103
+ }) => Promise<CommandResult>;
104
+ }): Promise<void>;
92
105
  export declare function runKnowledgeParsers(input: {
93
106
  files: KnowledgeParserInput[];
94
107
  outputDir: string;
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/knowledge/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,KAAK,eAAe,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAA;CAAE,CAAC;AAK7F,OAAO,EAAE,KAAK,SAAS,EAA0C,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAKxD,OAAO,EAAuB,KAAK,MAAM,EAAgB,MAAM,6BAA6B,CAAC;A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;IAC1F,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GACA,OAAO,CAAC;IACT,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,MAAM,EAAE,+BAA+B,EAAE,CAAC;CAC3C,CAAC,CAsGD;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwItE"}
@@ -2,6 +2,7 @@ import * as dntShim from "../../../_dnt.shims.js";
2
2
  import { z } from "zod";
3
3
  import { createFileSystem, getEnv } from "../../../src/platform/index.js";
4
4
  import { basename, extname, join, normalize, relative } from "../../../src/platform/compat/path/index.js";
5
+ import { runCommand } from "../../../src/platform/compat/process.js";
5
6
  import { withSpan } from "../../../src/observability/tracing/otlp-setup.js";
6
7
  import { cliLogger } from "../../utils/index.js";
7
8
  import { createApiClient, resolveConfigWithAuth } from "../../shared/config.js";
@@ -356,6 +357,51 @@ export async function runKnowledgeParser(input) {
356
357
  }
357
358
  return result;
358
359
  }
360
+ function isMissingPythonExecutableError(error) {
361
+ if (!(error instanceof Error)) {
362
+ return false;
363
+ }
364
+ const errorWithCode = error;
365
+ if (errorWithCode.code === "ENOENT") {
366
+ return true;
367
+ }
368
+ return error.name === "NotFound" ||
369
+ /\bENOENT\b/i.test(error.message) ||
370
+ /not found/i.test(error.message) ||
371
+ /no such file or directory/i.test(error.message);
372
+ }
373
+ export async function executeKnowledgeParserCommand(input, deps = {}) {
374
+ const runCommandFn = deps.runCommandFn ?? runCommand;
375
+ let result;
376
+ try {
377
+ result = await runCommandFn("python3", {
378
+ args: [
379
+ input.scriptPath,
380
+ "--input-json",
381
+ input.inputJsonPath,
382
+ "--output-json",
383
+ input.outputJsonPath,
384
+ ],
385
+ ...(input.env ? { env: input.env } : {}),
386
+ capture: true,
387
+ });
388
+ }
389
+ catch (error) {
390
+ if (isMissingPythonExecutableError(error)) {
391
+ throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
392
+ }
393
+ throw error;
394
+ }
395
+ if (result.success) {
396
+ return;
397
+ }
398
+ const stderr = result.stderr?.trim();
399
+ const stdout = result.stdout?.trim();
400
+ if (result.code === 1 && !stderr && !stdout) {
401
+ throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
402
+ }
403
+ throw new Error(stderr || stdout || "parser exited unsuccessfully");
404
+ }
359
405
  export async function runKnowledgeParsers(input) {
360
406
  if (!input.files.length) {
361
407
  return [];
@@ -376,25 +422,12 @@ export async function runKnowledgeParsers(input) {
376
422
  output_dir: input.outputDir,
377
423
  }));
378
424
  await dntShim.Deno.writeTextFile(scriptPath, knowledgeIngestPythonSource);
379
- let result;
380
- try {
381
- result = await new dntShim.Deno.Command("python3", {
382
- args: [scriptPath, "--input-json", inputJsonPath, "--output-json", outputJsonPath],
383
- ...(input.env ? { env: input.env } : {}),
384
- stdout: "piped",
385
- stderr: "piped",
386
- }).output();
387
- }
388
- catch (error) {
389
- if (error instanceof dntShim.Deno.errors.NotFound) {
390
- throw new Error("python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.");
391
- }
392
- throw error;
393
- }
394
- if (result.code !== 0) {
395
- const stderr = new TextDecoder().decode(result.stderr).trim();
396
- throw new Error(stderr || "parser exited unsuccessfully");
397
- }
425
+ await executeKnowledgeParserCommand({
426
+ scriptPath,
427
+ inputJsonPath,
428
+ outputJsonPath,
429
+ env: input.env,
430
+ });
398
431
  const raw = await dntShim.Deno.readTextFile(outputJsonPath);
399
432
  const parsed = JSON.parse(raw);
400
433
  return Array.isArray(parsed) ? parsed : [parsed];
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.200",
3
+ "version": "0.1.201",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.200";
1
+ export declare const VERSION = "0.1.201";
2
2
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.200";
3
+ export const VERSION = "0.1.201";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.200",
3
+ "version": "0.1.201",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  type SafeParseResult<T> = { success: true; data: T } | { success: false; error: z.ZodError };
4
4
  import { createFileSystem, getEnv } from "../../../src/platform/index.js";
5
5
  import { basename, extname, join, normalize, relative } from "../../../src/platform/compat/path/index.js";
6
+ import { type CommandResult, runCommand } from "../../../src/platform/compat/process.js";
6
7
  import { withSpan } from "../../../src/observability/tracing/otlp-setup.js";
7
8
  import { cliLogger } from "../../utils/index.js";
8
9
  import { type ApiClient, createApiClient, resolveConfigWithAuth } from "../../shared/config.js";
@@ -485,6 +486,76 @@ export async function runKnowledgeParser(input: {
485
486
  return result;
486
487
  }
487
488
 
489
+ function isMissingPythonExecutableError(error: unknown): boolean {
490
+ if (!(error instanceof Error)) {
491
+ return false;
492
+ }
493
+
494
+ const errorWithCode = error as Error & { code?: unknown };
495
+ if (errorWithCode.code === "ENOENT") {
496
+ return true;
497
+ }
498
+
499
+ return error.name === "NotFound" ||
500
+ /\bENOENT\b/i.test(error.message) ||
501
+ /not found/i.test(error.message) ||
502
+ /no such file or directory/i.test(error.message);
503
+ }
504
+
505
+ export async function executeKnowledgeParserCommand(input: {
506
+ scriptPath: string;
507
+ inputJsonPath: string;
508
+ outputJsonPath: string;
509
+ env?: Record<string, string>;
510
+ }, deps: {
511
+ runCommandFn?: (
512
+ cmd: string,
513
+ options: {
514
+ args: string[];
515
+ env?: Record<string, string>;
516
+ capture: true;
517
+ },
518
+ ) => Promise<CommandResult>;
519
+ } = {}): Promise<void> {
520
+ const runCommandFn = deps.runCommandFn ?? runCommand;
521
+ let result: CommandResult;
522
+ try {
523
+ result = await runCommandFn("python3", {
524
+ args: [
525
+ input.scriptPath,
526
+ "--input-json",
527
+ input.inputJsonPath,
528
+ "--output-json",
529
+ input.outputJsonPath,
530
+ ],
531
+ ...(input.env ? { env: input.env } : {}),
532
+ capture: true,
533
+ });
534
+ } catch (error) {
535
+ if (isMissingPythonExecutableError(error)) {
536
+ throw new Error(
537
+ "python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
538
+ );
539
+ }
540
+ throw error;
541
+ }
542
+
543
+ if (result.success) {
544
+ return;
545
+ }
546
+
547
+ const stderr = result.stderr?.trim();
548
+ const stdout = result.stdout?.trim();
549
+
550
+ if (result.code === 1 && !stderr && !stdout) {
551
+ throw new Error(
552
+ "python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
553
+ );
554
+ }
555
+
556
+ throw new Error(stderr || stdout || "parser exited unsuccessfully");
557
+ }
558
+
488
559
  export async function runKnowledgeParsers(input: {
489
560
  files: KnowledgeParserInput[];
490
561
  outputDir: string;
@@ -515,27 +586,12 @@ export async function runKnowledgeParsers(input: {
515
586
  );
516
587
  await dntShim.Deno.writeTextFile(scriptPath, knowledgeIngestPythonSource);
517
588
 
518
- let result: dntShim.Deno.CommandOutput;
519
- try {
520
- result = await new dntShim.Deno.Command("python3", {
521
- args: [scriptPath, "--input-json", inputJsonPath, "--output-json", outputJsonPath],
522
- ...(input.env ? { env: input.env } : {}),
523
- stdout: "piped",
524
- stderr: "piped",
525
- }).output();
526
- } catch (error) {
527
- if (error instanceof dntShim.Deno.errors.NotFound) {
528
- throw new Error(
529
- "python3 is required. Install python3 and the supported parser packages, or run the command inside the Veryfront sandbox.",
530
- );
531
- }
532
- throw error;
533
- }
534
-
535
- if (result.code !== 0) {
536
- const stderr = new TextDecoder().decode(result.stderr).trim();
537
- throw new Error(stderr || "parser exited unsuccessfully");
538
- }
589
+ await executeKnowledgeParserCommand({
590
+ scriptPath,
591
+ inputJsonPath,
592
+ outputJsonPath,
593
+ env: input.env,
594
+ });
539
595
 
540
596
  const raw = await dntShim.Deno.readTextFile(outputJsonPath);
541
597
  const parsed = JSON.parse(raw) as KnowledgeParserResult | KnowledgeParserResult[];
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.200",
3
+ "version": "0.1.201",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.200";
3
+ export const VERSION = "0.1.201";