@toolforge-js/sdk 0.8.5 → 0.8.6

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/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { C as __toESM, S as __require, _ as stopToolMessageSchema, a as AGENT_TAG_NAME, b as invariant, c as runWithRetries, d as heartbeatAckMessageSchema, f as initCommunicationMessageSchema, g as stopAgentMessageSchema, h as startToolMessageSchema, i as AGENT_STEP_TAG_NAME, l as ackMessageSchema, m as startAgentMessageSchema, n as TOOL_TAG_NAME, o as Agent, p as runnerId, r as Tool, s as exponentialBackoff, t as TOOL_HANDLER_TAG_NAME, u as baseMessageSchema, v as convertToWords, x as __commonJS, y as getErrorMessage } from "../tool-BHVNhWPh.js";
2
- import { r as toolForgeConfigSchema } from "../config-schema-D6ZIesbW.js";
2
+ import { a as sdkServerUrlSchema, n as appServerUrlSchema, o as toolForgeConfigSchema, r as appUrlSchema } from "../config-schema-Bb9oY-Ku.js";
3
3
  import { createReadStream, readFileSync } from "node:fs";
4
4
  import * as path from "node:path";
5
5
  import { EventEmitter } from "node:events";
@@ -3514,7 +3514,8 @@ async function deploy(configRelPath, debug) {
3514
3514
  });
3515
3515
  const envSpinner = prompts.spinner();
3516
3516
  envSpinner.start("Fetching production environments...");
3517
- const { environments } = await fetch(new URL("/api/cli/production-environments", config.appServerUrl), { headers: { "x-tf-token": key } }).then(async (res) => {
3517
+ const appServerUrl = appServerUrlSchema.parse(process.env.APP_SERVER_URL);
3518
+ const { environments } = await fetch(new URL("/api/cli/production-environments", appServerUrl), { headers: { "x-tf-token": key } }).then(async (res) => {
3518
3519
  if (!res.ok) throw new Error(`Failed to fetch production environments: ${res.status} ${res.statusText}`);
3519
3520
  const data = z$1.object({ environments: z$1.object({
3520
3521
  id: z$1.string(),
@@ -3574,7 +3575,7 @@ async function deploy(configRelPath, debug) {
3574
3575
  formData.append("environmentId", environmentSelect);
3575
3576
  formData.append("sha256", sha256);
3576
3577
  formData.append("name", name);
3577
- const { url } = await fetch(new URL("/api/cli/initialize-deployment", config.appServerUrl), {
3578
+ const { url } = await fetch(new URL("/api/cli/initialize-deployment", appServerUrl), {
3578
3579
  method: "POST",
3579
3580
  headers: { "x-tf-token": key },
3580
3581
  body: formData
@@ -3595,21 +3596,21 @@ async function deploy(configRelPath, debug) {
3595
3596
  prompts.outro(getErrorMessage(error));
3596
3597
  process.exit(1);
3597
3598
  });
3598
- const deploymentUrl = new URL(url, config.appUrl).toString();
3599
+ const appUrl = appUrlSchema.parse(process.env.APP_URL);
3600
+ const deploymentUrl = new URL(url, appUrl).toString();
3599
3601
  prompts.outro(`Deployment initiated successfully!\n\nYou can view the deployment status at:\n${picocolors.green(deploymentUrl)}`);
3600
3602
  }
3601
3603
 
3602
3604
  //#endregion
3603
3605
  //#region src/cli/actions/login.ts
3604
- async function login(configRelPath) {
3606
+ async function login() {
3605
3607
  prompts.intro("Logging in to Tool Forge");
3606
3608
  const spinner = prompts.spinner();
3607
3609
  spinner.start("Loading configuration...");
3608
3610
  try {
3609
- const { config } = await getToolForgeConfig(configRelPath);
3610
3611
  spinner.stop("Configuration loaded.");
3611
3612
  const authClient = createAuthClient({
3612
- baseURL: config.appServerUrl,
3613
+ baseURL: appServerUrlSchema.parse(process.env.APP_SERVER_URL),
3613
3614
  plugins: [deviceAuthorizationClient()]
3614
3615
  });
3615
3616
  const deviceLabel = getDeviceLabel();
@@ -3622,7 +3623,8 @@ async function login(configRelPath) {
3622
3623
  prompts.outro(`failed to initiate device authorization flow: ${error.error_description}`);
3623
3624
  process.exit(1);
3624
3625
  }
3625
- const verificationUrl = new URL("/cli/login", config.appUrl);
3626
+ const appUrl = appUrlSchema.parse(process.env.APP_URL);
3627
+ const verificationUrl = new URL("/cli/login", appUrl);
3626
3628
  verificationUrl.searchParams.set("deviceLabel", deviceLabel);
3627
3629
  verificationUrl.searchParams.set("userCode", deviceCodeData.user_code);
3628
3630
  prompts.note(`To authenticate, please visit:\n${verificationUrl.toString()}\n\nšŸ” And enter the code: ${deviceCodeData.user_code}`, "Login Instructions");
@@ -4284,7 +4286,7 @@ async function startToolForge({ configRelPath, debug, mode }) {
4284
4286
  const { config, configPath } = await getToolForgeConfig(configRelPath);
4285
4287
  spinner.stop();
4286
4288
  logger.debug({ config }, "loaded config from %s", configPath);
4287
- const sdkServerUrl = z$1.url().parse(process.env.SDK_SERVER_URL);
4289
+ const sdkServerUrl = sdkServerUrlSchema.parse(process.env.SDK_SERVER_URL);
4288
4290
  let apiKey;
4289
4291
  if (config.apiKey) apiKey = config.apiKey;
4290
4292
  else {
@@ -4359,8 +4361,8 @@ program.command("build").description("build the tools for production").option("-
4359
4361
  const debug = z$1.boolean().optional().default(false).parse(this.opts().debug);
4360
4362
  await build(z$1.string().parse(this.opts().config), debug);
4361
4363
  });
4362
- program.command("login").description("login to Tool Forge").option("-c, --config <path>", "path to the tool-forge config file", (val) => z$1.string().parse(val), "toolforge.config.ts").action(async function() {
4363
- await login(z$1.string().parse(this.opts().config));
4364
+ program.command("login").description("login to Tool Forge").action(async function() {
4365
+ await login();
4364
4366
  });
4365
4367
  program.command("deploy").description("deploy the tools to Tool Forge").option("-c, --config <path>", "path to the tool-forge config file", (val) => z$1.string().parse(val), "toolforge.config.ts").option("-d, --debug", "enable debug logging", false).action(async function() {
4366
4368
  await deploy(z$1.string().parse(this.opts().config), z$1.boolean().optional().default(false).parse(this.opts().debug));
@@ -15,9 +15,6 @@ type ToolForgeConfig = {
15
15
  * @param config - The configuration object for Tool Forge SDK.
16
16
  */
17
17
  declare function defineConfig(input: ToolForgeConfig): {
18
- sdkServerUrl: string;
19
- appServerUrl: string;
20
- appUrl: string;
21
18
  toolsDir: string;
22
19
  maxRetries: number;
23
20
  apiKey?: string | undefined;
@@ -1,4 +1,4 @@
1
- import { i as urlConfigSchema, n as baseConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-D6ZIesbW.js";
1
+ import { i as baseConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-Bb9oY-Ku.js";
2
2
  import * as z$1 from "zod";
3
3
 
4
4
  //#region src/config/index.ts
@@ -13,19 +13,9 @@ function defineConfig(input) {
13
13
  const { errors } = z$1.treeifyError(parsedInput.error);
14
14
  throw new Error(`invalid input. ${errors.join(", ")}`);
15
15
  }
16
- const parsedUrls = urlConfigSchema.safeParse({
17
- sdkServerUrl: process.env.SDK_SERVER_URL,
18
- appServerUrl: process.env.APP_SERVER_URL,
19
- appUrl: process.env.APP_URL
20
- });
21
- if (!parsedUrls.success) {
22
- const { errors } = z$1.treeifyError(parsedUrls.error);
23
- throw new Error(`invalid urls. ${errors.join(", ")}`);
24
- }
25
16
  return {
26
17
  __tf__tag__name__: TF_CONFIG_TAG_NAME,
27
- ...parsedInput.data,
28
- ...parsedUrls.data
18
+ ...parsedInput.data
29
19
  };
30
20
  }
31
21
 
@@ -0,0 +1,16 @@
1
+ import * as z$1 from "zod";
2
+
3
+ //#region src/config/config-schema.ts
4
+ const sdkServerUrlSchema = z$1.url().describe("URL of the Tool Forge SDK server").optional().default("https://sdk.tool-forge.ai");
5
+ const appServerUrlSchema = z$1.url().optional().describe("URL of the Tool Forge application server").default("https://api.tool-forge.ai");
6
+ const appUrlSchema = z$1.url().optional().describe("URL of the Tool Forge application").default("https://app.tool-forge.ai");
7
+ const baseConfigSchema = z$1.object({
8
+ toolsDir: z$1.string().describe("Directory where the tools are located").optional().default("tools"),
9
+ apiKey: z$1.string().describe("API key for authenticating with the Tool Forge platform").refine((val) => val.startsWith("sk_live") || val.startsWith("pk_test"), { message: "API key must start with sk_live, pk_test" }).describe("API key for authenticating with the Tool Forge platform.").optional(),
10
+ maxRetries: z$1.number().optional().default(100)
11
+ });
12
+ const TF_CONFIG_TAG_NAME = Symbol("TOOL_FORGE_CONFIG");
13
+ const toolForgeConfigSchema = baseConfigSchema.and(z$1.object({ __tf__tag__name__: z$1.symbol(TF_CONFIG_TAG_NAME.description) }));
14
+
15
+ //#endregion
16
+ export { sdkServerUrlSchema as a, baseConfigSchema as i, appServerUrlSchema as n, toolForgeConfigSchema as o, appUrlSchema as r, TF_CONFIG_TAG_NAME as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolforge-js/sdk",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -1,18 +0,0 @@
1
- import * as z$1 from "zod";
2
-
3
- //#region src/config/config-schema.ts
4
- const urlConfigSchema = z$1.object({
5
- sdkServerUrl: z$1.url().describe("URL of the Tool Forge SDK server").optional().default("https://sdk.tool-forge.ai"),
6
- appServerUrl: z$1.url().optional().describe("URL of the Tool Forge application server").default("https://api.tool-forge.ai"),
7
- appUrl: z$1.url().optional().describe("URL of the Tool Forge application").default("https://app.tool-forge.ai")
8
- });
9
- const baseConfigSchema = z$1.object({
10
- toolsDir: z$1.string().describe("Directory where the tools are located").optional().default("tools"),
11
- apiKey: z$1.string().describe("API key for authenticating with the Tool Forge platform").refine((val) => val.startsWith("sk_live") || val.startsWith("pk_test"), { message: "API key must start with sk_live, pk_test" }).describe("API key for authenticating with the Tool Forge platform.").optional(),
12
- maxRetries: z$1.number().optional().default(100)
13
- });
14
- const TF_CONFIG_TAG_NAME = Symbol("TOOL_FORGE_CONFIG");
15
- const toolForgeConfigSchema = baseConfigSchema.and(urlConfigSchema).and(z$1.object({ __tf__tag__name__: z$1.symbol(TF_CONFIG_TAG_NAME.description) }));
16
-
17
- //#endregion
18
- export { urlConfigSchema as i, baseConfigSchema as n, toolForgeConfigSchema as r, TF_CONFIG_TAG_NAME as t };