@langchain/langgraph-cli 0.0.0-preview.6 → 0.0.0-preview.7

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.
@@ -8,6 +8,7 @@ import { $ } from "execa";
8
8
  import * as path from "node:path";
9
9
  import * as fs from "node:fs/promises";
10
10
  import { logger } from "../logging.mjs";
11
+ import { withAnalytics } from "./utils/analytics.mjs";
11
12
  const stream = (proc) => {
12
13
  logger.info(`Running "${proc.spawnargs.join(" ")}"`);
13
14
  return proc;
@@ -20,6 +21,10 @@ builder
20
21
  .option("--no-pull", "Running the server with locally-built images. By default LangGraph will pull the latest images from the registry")
21
22
  .argument("[args...]")
22
23
  .passThroughOptions()
24
+ .hook("preAction", withAnalytics((command) => ({
25
+ config: command.opts().config !== process.cwd(),
26
+ pull: command.opts().pull,
27
+ })))
23
28
  .action(async (pass, params) => {
24
29
  const configPath = await getProjectPath(params.config);
25
30
  await getDockerCapabilities();
package/dist/cli/cli.mjs CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { builder } from "./utils/builder.mjs";
3
+ import { flushAnalytics } from "./utils/analytics.mjs";
4
+ import { asyncExitHook, gracefulExit } from "exit-hook";
3
5
  import "./dev.mjs";
4
6
  import "./docker.mjs";
5
7
  import "./build.mjs";
6
8
  import "./up.mjs";
9
+ builder.exitOverride((error) => gracefulExit(error.exitCode));
10
+ asyncExitHook(() => flushAnalytics(), { wait: 2000 });
7
11
  builder.parse();
package/dist/cli/dev.mjs CHANGED
@@ -9,6 +9,7 @@ import { getProjectPath } from "./utils/project.mjs";
9
9
  import { getConfig } from "../utils/config.mjs";
10
10
  import { builder } from "./utils/builder.mjs";
11
11
  import { logger } from "../logging.mjs";
12
+ import { withAnalytics } from "./utils/analytics.mjs";
12
13
  builder
13
14
  .command("dev")
14
15
  .description("Run LangGraph API server in development mode with hot reloading.")
@@ -19,6 +20,12 @@ builder
19
20
  .option("-c, --config <path>", "path to configuration file", process.cwd())
20
21
  .allowExcessArguments()
21
22
  .allowUnknownOption()
23
+ .hook("preAction", withAnalytics((command) => ({
24
+ config: command.opts().config !== process.cwd(),
25
+ port: command.opts().port !== "2024",
26
+ host: command.opts().host !== "localhost",
27
+ n_jobs_per_worker: command.opts().nJobsPerWorker !== "10",
28
+ })))
22
29
  .action(async (options, { args }) => {
23
30
  try {
24
31
  const configPath = await getProjectPath(options.config);
@@ -7,6 +7,7 @@ import * as fs from "node:fs/promises";
7
7
  import * as path from "node:path";
8
8
  import dedent from "dedent";
9
9
  import { logger } from "../logging.mjs";
10
+ import { withAnalytics } from "./utils/analytics.mjs";
10
11
  const fileExists = async (path) => {
11
12
  try {
12
13
  await fs.access(path);
@@ -22,6 +23,10 @@ builder
22
23
  .argument("<save-path>", "Path to save the Dockerfile")
23
24
  .option("--add-docker-compose", "Add additional files for running the LangGraph API server with docker-compose. These files include a docker-compose.yml, .env file, and a .dockerignore file.")
24
25
  .option("-c, --config <path>", "Path to configuration file", process.cwd())
26
+ .hook("preAction", withAnalytics((command) => ({
27
+ config: command.opts().config !== process.cwd(),
28
+ add_docker_compose: !!command.opts().addDockerCompose,
29
+ })))
25
30
  .action(async (savePath, options) => {
26
31
  const configPath = await getProjectPath(options.config);
27
32
  const config = getConfig(await fs.readFile(configPath, "utf-8"));
package/dist/cli/up.mjs CHANGED
@@ -10,6 +10,7 @@ import { getExecaOptions } from "../docker/shell.mjs";
10
10
  import { $ } from "execa";
11
11
  import { createHash } from "node:crypto";
12
12
  import dedent from "dedent";
13
+ import { withAnalytics } from "./utils/analytics.mjs";
13
14
  const sha256 = (input) => createHash("sha256").update(input).digest("hex");
14
15
  const getProjectName = (configPath) => {
15
16
  const cwd = path.dirname(configPath).toLocaleLowerCase();
@@ -40,6 +41,16 @@ builder
40
41
  .option("--watch", "Restart on file changes", false)
41
42
  .option("--wait", "Wait for services to start before returning. Implies --detach", false)
42
43
  .option("--postgres-uri <uri>", "Postgres URI to use for the database. Defaults to launching a local database")
44
+ .hook("preAction", withAnalytics((command) => ({
45
+ config: command.opts().config !== process.cwd(),
46
+ port: command.opts().port !== "8123",
47
+ postgres_uri: !!command.opts().postgresUri,
48
+ docker_compose: !!command.opts().dockerCompose,
49
+ recreate: command.opts().recreate,
50
+ pull: command.opts().pull,
51
+ watch: command.opts().watch,
52
+ wait: command.opts().wait,
53
+ })))
43
54
  .action(async (params) => {
44
55
  logger.info("Starting LangGraph API server...");
45
56
  logger.warn(dedent `
@@ -0,0 +1,39 @@
1
+ import os from "node:os";
2
+ import { version } from "./version.mjs";
3
+ const SUPABASE_PUBLIC_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt6cmxwcG9qaW5wY3l5YWlweG5iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTkyNTc1NzksImV4cCI6MjAzNDgzMzU3OX0.kkVOlLz3BxemA5nP-vat3K4qRtrDuO4SwZSR_htcX9c";
4
+ const SUPABASE_URL = "https://kzrlppojinpcyyaipxnb.supabase.co";
5
+ async function logData(data) {
6
+ try {
7
+ await fetch(`${SUPABASE_URL}/rest/v1/js_logs`, {
8
+ method: "POST",
9
+ headers: {
10
+ "Content-Type": "application/json",
11
+ apikey: SUPABASE_PUBLIC_API_KEY,
12
+ "User-Agent": "Mozilla/5.0",
13
+ },
14
+ body: JSON.stringify(data),
15
+ });
16
+ }
17
+ catch (error) {
18
+ // pass
19
+ }
20
+ }
21
+ let analyticsPromise = Promise.resolve();
22
+ export function withAnalytics(fn) {
23
+ if (process.env.LANGGRAPH_CLI_NO_ANALYTICS === "1") {
24
+ return () => void 0;
25
+ }
26
+ return function (actionCommand) {
27
+ analyticsPromise = analyticsPromise.then(() => logData({
28
+ os: os.platform(),
29
+ os_version: os.release(),
30
+ node_version: process.version,
31
+ cli_version: version,
32
+ cli_command: actionCommand.name(),
33
+ params: fn?.(actionCommand) ?? {},
34
+ }).catch(() => { }));
35
+ };
36
+ }
37
+ export async function flushAnalytics() {
38
+ await analyticsPromise;
39
+ }
@@ -1,16 +1,7 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- import * as fs from "node:fs/promises";
3
- import * as url from "node:url";
2
+ import { version } from "./version.mjs";
4
3
  export const builder = new Command()
5
4
  .name("langgraph")
6
5
  .description("LangGraph.js CLI")
6
+ .version(version)
7
7
  .enablePositionalOptions();
8
- try {
9
- const packageJson = url.fileURLToPath(new URL("../../../package.json", import.meta.url));
10
- const { version } = JSON.parse(await fs.readFile(packageJson, "utf-8"));
11
- builder.version(version);
12
- }
13
- catch (error) {
14
- console.error(error);
15
- // pass
16
- }
@@ -0,0 +1,13 @@
1
+ import * as fs from "node:fs/promises";
2
+ import * as url from "node:url";
3
+ async function getVersion() {
4
+ try {
5
+ const packageJson = url.fileURLToPath(new URL("../../../package.json", import.meta.url));
6
+ const { version } = JSON.parse(await fs.readFile(packageJson, "utf-8"));
7
+ return version + "+js";
8
+ }
9
+ catch {
10
+ return "0.0.0-unknown";
11
+ }
12
+ }
13
+ export const version = await getVersion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph-cli",
3
- "version": "0.0.0-preview.6",
3
+ "version": "0.0.0-preview.7",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=18"