@toolforge-js/sdk 0.8.3 → 0.8.4

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,10 +1,10 @@
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-DDDEH8M3.js";
2
- import { n as toolForgeConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-V_1JIDL9.js";
3
- import * as z$1 from "zod";
4
- import z from "zod";
2
+ import { r as toolForgeConfigSchema } from "../config-schema-D6ZIesbW.js";
5
3
  import { createReadStream, readFileSync } from "node:fs";
6
4
  import * as path from "node:path";
7
5
  import { EventEmitter } from "node:events";
6
+ import * as z$1 from "zod";
7
+ import z from "zod";
8
8
  import ora from "ora";
9
9
  import { pino } from "pino";
10
10
  import * as crypto from "node:crypto";
@@ -3284,7 +3284,7 @@ async function getToolForgeConfig(configRelPath) {
3284
3284
  try {
3285
3285
  const configPath = path.resolve(process.cwd(), configRelPath);
3286
3286
  return {
3287
- config: toolForgeConfigSchema.extend({ __tf__tag__name__: z$1.symbol(TF_CONFIG_TAG_NAME.description) }).parse(await import(configPath).then((mod) => mod.default)),
3287
+ config: toolForgeConfigSchema.parse(await import(configPath).then((mod) => mod.default)),
3288
3288
  configPath
3289
3289
  };
3290
3290
  } catch (error) {
@@ -4008,7 +4008,7 @@ var ForgeRunner = class extends EventEmitter {
4008
4008
  #options;
4009
4009
  #logger;
4010
4010
  #config;
4011
- #serverUrl;
4011
+ #sdkServerUrl;
4012
4012
  #apiKey;
4013
4013
  #refreshApiKeyInterval;
4014
4014
  #forgeItems = [];
@@ -4028,15 +4028,15 @@ var ForgeRunner = class extends EventEmitter {
4028
4028
  if (!token.startsWith(TOKEN_PREFIX)) throw new Error(`API key in ${process.env[TOOL_FORGE_TOKEN_FILE]} is invalid`);
4029
4029
  this.#apiKey = token;
4030
4030
  } else throw new Error("API key is required to initialize ForgeRunner");
4031
- const url = new URL(this.#config.sdkServer);
4031
+ const url = new URL(this.#config.sdkServerUrl);
4032
4032
  url.searchParams.set("apiKey", this.#apiKey);
4033
4033
  url.searchParams.set("runnerId", this.#id);
4034
4034
  url.pathname = "/socket";
4035
- this.#serverUrl = url.toString();
4035
+ this.#sdkServerUrl = url.toString();
4036
4036
  this.#options = optionsSchema.parse(options);
4037
4037
  this.#logger = logger.child({ id: this.#id });
4038
4038
  this.#webSocketClient = new WebSocketClient({
4039
- serverUrl: this.#serverUrl,
4039
+ serverUrl: this.#sdkServerUrl,
4040
4040
  runnerId: this.#id
4041
4041
  }, this, this.#logger);
4042
4042
  this.#webSocketClient.on(WEB_SOCKET_CLIENT_EVENTS.COMMUNICATION_INITIALIZED, this.#handleWebSocketCommunicationInitialized.bind(this));
@@ -4234,7 +4234,7 @@ var ForgeRunner = class extends EventEmitter {
4234
4234
  * using Tool Forge Cloud.
4235
4235
  */
4236
4236
  async #refreshApiKey() {
4237
- const url = new URL(this.#serverUrl);
4237
+ const url = new URL(this.#sdkServerUrl);
4238
4238
  url.pathname = "/token/refresh";
4239
4239
  const res = await fetch(url.toString(), {
4240
4240
  method: "POST",
@@ -1,5 +1,5 @@
1
- import * as z$1 from "zod";
2
1
  import { EventEmitter } from "node:events";
2
+ import * as z$1 from "zod";
3
3
  import { Logger } from "pino";
4
4
  import * as better_auth0 from "better-auth";
5
5
 
@@ -6084,14 +6084,17 @@ declare class Block {
6084
6084
  }
6085
6085
  //#endregion
6086
6086
  //#region src/config/config-schema.d.ts
6087
- declare const toolForgeConfigSchema: z$1.ZodObject<{
6087
+ declare const toolForgeConfigSchema: z$1.ZodIntersection<z$1.ZodIntersection<z$1.ZodObject<{
6088
6088
  toolsDir: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
6089
6089
  apiKey: z$1.ZodOptional<z$1.ZodString>;
6090
- sdkServer: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6090
+ maxRetries: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
6091
+ }, z$1.core.$strip>, z$1.ZodObject<{
6092
+ sdkServerUrl: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6091
6093
  appServerUrl: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6092
6094
  appUrl: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6093
- maxRetries: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
6094
- }, z$1.core.$strip>;
6095
+ }, z$1.core.$strip>>, z$1.ZodObject<{
6096
+ __tf__tag__name__: z$1.ZodSymbol;
6097
+ }, z$1.core.$strip>>;
6095
6098
  type ToolForgeConfig = z$1.infer<typeof toolForgeConfigSchema>;
6096
6099
  //#endregion
6097
6100
  //#region src/internal/forge-runner.d.ts
@@ -8,12 +8,6 @@ type ToolForgeConfig = {
8
8
  * Get your API key from the Tool Forge environment dashboard.
9
9
  */
10
10
  apiKey?: string;
11
- /** Optional URL for the SDK server (overrides default). */
12
- sdkServer?: string;
13
- /** Optional URL for the Tool Forge app server (overrides default). */
14
- appServerUrl?: string;
15
- /** Optional URL for the Tool Forge app (overrides default). */
16
- appUrl?: string;
17
11
  };
18
12
  /**
19
13
  * Define and validate Tool Forge SDK configuration.
@@ -21,10 +15,10 @@ type ToolForgeConfig = {
21
15
  * @param config - The configuration object for Tool Forge SDK.
22
16
  */
23
17
  declare function defineConfig(input: ToolForgeConfig): {
24
- toolsDir: string;
25
- sdkServer: string;
18
+ sdkServerUrl: string;
26
19
  appServerUrl: string;
27
20
  appUrl: string;
21
+ toolsDir: string;
28
22
  maxRetries: number;
29
23
  apiKey?: string | undefined;
30
24
  __tf__tag__name__: symbol;
@@ -1,4 +1,5 @@
1
- import { n as toolForgeConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-V_1JIDL9.js";
1
+ import { i as urlConfigSchema, n as baseConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-D6ZIesbW.js";
2
+ import * as z$1 from "zod";
2
3
 
3
4
  //#region src/config/index.ts
4
5
  /**
@@ -7,9 +8,24 @@ import { n as toolForgeConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-s
7
8
  * @param config - The configuration object for Tool Forge SDK.
8
9
  */
9
10
  function defineConfig(input) {
11
+ const parsedInput = baseConfigSchema.safeParse(input);
12
+ if (!parsedInput.success) {
13
+ const { errors } = z$1.treeifyError(parsedInput.error);
14
+ throw new Error(`invalid input. ${errors.join(", ")}`);
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
+ }
10
25
  return {
11
26
  __tf__tag__name__: TF_CONFIG_TAG_NAME,
12
- ...toolForgeConfigSchema.parse(input)
27
+ ...parsedInput.data,
28
+ ...parsedUrls.data
13
29
  };
14
30
  }
15
31
 
@@ -1,15 +1,18 @@
1
1
  import * as z$1 from "zod";
2
2
 
3
3
  //#region src/config/config-schema.ts
4
- const toolForgeConfigSchema = z$1.object({
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({
5
10
  toolsDir: z$1.string().describe("Directory where the tools are located").optional().default("tools"),
6
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(),
7
- sdkServer: z$1.url().describe("URL of the Tool Forge SDK server").optional().default("https://sdk.tool-forge.ai"),
8
- appServerUrl: z$1.url().optional().describe("URL of the Tool Forge application server").default("https://api.tool-forge.ai"),
9
- appUrl: z$1.url().optional().describe("URL of the Tool Forge application").default("https://app.tool-forge.ai"),
10
12
  maxRetries: z$1.number().optional().default(100)
11
13
  });
12
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) }));
13
16
 
14
17
  //#endregion
15
- export { toolForgeConfigSchema as n, TF_CONFIG_TAG_NAME as t };
18
+ export { urlConfigSchema as i, baseConfigSchema as n, toolForgeConfigSchema 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.3",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",