@toolforge-js/sdk 0.8.4 → 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
- 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 { r as toolForgeConfigSchema } from "../config-schema-D6ZIesbW.js";
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 { 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");
@@ -3692,7 +3694,6 @@ function getDeviceLabel() {
3692
3694
  //#endregion
3693
3695
  //#region ../core/dist/token/index.js
3694
3696
  const TOKEN_PREFIX = "tf_token--";
3695
- const TOOL_FORGE_TOKEN_FILE = "TOOL_FORGE_TOKEN_FILE";
3696
3697
 
3697
3698
  //#endregion
3698
3699
  //#region src/internal/websocket-client.ts
@@ -3990,13 +3991,22 @@ var WebSocketClient = class extends EventEmitter {
3990
3991
 
3991
3992
  //#endregion
3992
3993
  //#region src/internal/forge-runner.ts
3994
+ /**
3995
+ * ForgeRunner should start with apiKey
3996
+ */
3993
3997
  const toForgeRunnerMessages = z$1.discriminatedUnion("type", [
3994
3998
  startToolMessageSchema,
3995
3999
  stopToolMessageSchema,
3996
4000
  startAgentMessageSchema,
3997
4001
  stopAgentMessageSchema
3998
4002
  ]);
3999
- const optionsSchema = z$1.object({ mode: z$1.enum(["development", "production"]) });
4003
+ const optionsSchema = z$1.object({
4004
+ mode: z$1.enum(["development", "production"]),
4005
+ apiKey: z$1.string().refine((val) => val.startsWith("sk_live") || val.startsWith("pk_test") || val.startsWith(TOKEN_PREFIX)),
4006
+ tokenProviderEndpoint: z$1.url().optional(),
4007
+ sdkServerUrl: z$1.url(),
4008
+ toolsDir: z$1.string()
4009
+ });
4000
4010
  /**
4001
4011
  * ForgeRunner manages the lifecycle of tools or agents, including discovery, loading, and communication with the SDK server.
4002
4012
  *
@@ -4007,9 +4017,8 @@ var ForgeRunner = class extends EventEmitter {
4007
4017
  #id = `tf-runner:${nanoid(32)}`;
4008
4018
  #options;
4009
4019
  #logger;
4010
- #config;
4011
- #sdkServerUrl;
4012
4020
  #apiKey;
4021
+ #sdkServerUrl;
4013
4022
  #refreshApiKeyInterval;
4014
4023
  #forgeItems = [];
4015
4024
  #tools = {};
@@ -4019,32 +4028,22 @@ var ForgeRunner = class extends EventEmitter {
4019
4028
  #fsWatcher;
4020
4029
  #sessionTools = /* @__PURE__ */ new Map();
4021
4030
  #sessionAgents = /* @__PURE__ */ new Map();
4022
- constructor(config, options, logger) {
4031
+ constructor(options, logger) {
4023
4032
  super({ captureRejections: true });
4024
- this.#config = config;
4025
- if (typeof config.apiKey === "string") this.#apiKey = config.apiKey;
4026
- else if (typeof process.env[TOOL_FORGE_TOKEN_FILE] === "string") {
4027
- const token = readFileSync(process.env[TOOL_FORGE_TOKEN_FILE], "utf-8").trim();
4028
- if (!token.startsWith(TOKEN_PREFIX)) throw new Error(`API key in ${process.env[TOOL_FORGE_TOKEN_FILE]} is invalid`);
4029
- this.#apiKey = token;
4030
- } else throw new Error("API key is required to initialize ForgeRunner");
4031
- const url = new URL(this.#config.sdkServerUrl);
4033
+ this.#options = optionsSchema.parse(options);
4034
+ this.#logger = logger.child({ id: this.#id });
4035
+ this.#apiKey = this.#options.apiKey;
4036
+ if (this.#apiKey.startsWith(TOKEN_PREFIX)) this.#refreshApiKeyInterval = setInterval(this.#refreshApiKey.bind(this), 840 * 1e3);
4037
+ const url = new URL(this.#options.sdkServerUrl);
4032
4038
  url.searchParams.set("apiKey", this.#apiKey);
4033
4039
  url.searchParams.set("runnerId", this.#id);
4034
4040
  url.pathname = "/socket";
4035
4041
  this.#sdkServerUrl = url.toString();
4036
- this.#options = optionsSchema.parse(options);
4037
- this.#logger = logger.child({ id: this.#id });
4038
4042
  this.#webSocketClient = new WebSocketClient({
4039
4043
  serverUrl: this.#sdkServerUrl,
4040
4044
  runnerId: this.#id
4041
4045
  }, this, this.#logger);
4042
4046
  this.#webSocketClient.on(WEB_SOCKET_CLIENT_EVENTS.COMMUNICATION_INITIALIZED, this.#handleWebSocketCommunicationInitialized.bind(this));
4043
- if (this.#apiKey.startsWith(TOKEN_PREFIX)) this.#refreshApiKeyInterval = setInterval(this.#refreshApiKey.bind(this), 840 * 1e3);
4044
- this.#logger.info({
4045
- mode: this.#options.mode,
4046
- id: this.#id
4047
- }, "created tool runner");
4048
4047
  this.#start();
4049
4048
  }
4050
4049
  get activeSessionsCount() {
@@ -4053,7 +4052,7 @@ var ForgeRunner = class extends EventEmitter {
4053
4052
  async #start() {
4054
4053
  try {
4055
4054
  this.#logger.debug("gathering tools...");
4056
- const { forgeItems, tools, agents } = await gatherForgeItems(path.resolve(process.cwd(), this.#config.toolsDir), this.#options.mode, this.#logger);
4055
+ const { forgeItems, tools, agents } = await gatherForgeItems(path.resolve(process.cwd(), this.#options.toolsDir), this.#options.mode, this.#logger);
4057
4056
  this.#forgeItems = forgeItems;
4058
4057
  this.#tools = tools;
4059
4058
  this.#agents = agents;
@@ -4089,7 +4088,6 @@ var ForgeRunner = class extends EventEmitter {
4089
4088
  */
4090
4089
  async #handleStartToolMessage(message) {
4091
4090
  this.#logger.debug({ message }, "received start tool message");
4092
- if (!this.#config) throw new Error("config should be initialized before starting tool");
4093
4091
  const { sessionId, itemId } = message.data;
4094
4092
  const toolDefinition = this.#tools[itemId];
4095
4093
  if (!toolDefinition) {
@@ -4146,7 +4144,7 @@ var ForgeRunner = class extends EventEmitter {
4146
4144
  this.#sessionTools.delete(sessionId);
4147
4145
  }
4148
4146
  #watchToolChanges() {
4149
- const resolvedToolsDir = path.resolve(process.cwd(), this.#config.toolsDir);
4147
+ const resolvedToolsDir = path.resolve(process.cwd(), this.#options.toolsDir);
4150
4148
  this.#fsWatcher = chokidar.watch(resolvedToolsDir, {
4151
4149
  ignored: /(^|[/\\])\../,
4152
4150
  persistent: true,
@@ -4162,7 +4160,7 @@ var ForgeRunner = class extends EventEmitter {
4162
4160
  }).otherwise(() => picocolors.blue("tools changed"));
4163
4161
  this.#logger.info(`${message}, reloading server...`);
4164
4162
  try {
4165
- const { forgeItems, tools, agents } = await gatherForgeItems(path.resolve(process.cwd(), this.#config.toolsDir), this.#options.mode, this.#logger);
4163
+ const { forgeItems, tools, agents } = await gatherForgeItems(path.resolve(process.cwd(), this.#options.toolsDir), this.#options.mode, this.#logger);
4166
4164
  this.#forgeItems = forgeItems;
4167
4165
  this.#tools = tools;
4168
4166
  this.#agents = agents;
@@ -4185,7 +4183,6 @@ var ForgeRunner = class extends EventEmitter {
4185
4183
  }
4186
4184
  #handleStartAgentMessage(message) {
4187
4185
  this.#logger.debug({ message }, "received start agent message");
4188
- if (!this.#config) throw new Error("config should be initialized before starting agent");
4189
4186
  const { sessionId, itemId } = message.data;
4190
4187
  const agentDefinition = this.#agents[itemId];
4191
4188
  if (!agentDefinition) {
@@ -4227,16 +4224,25 @@ var ForgeRunner = class extends EventEmitter {
4227
4224
  this.#sessionAgents.delete(sessionId);
4228
4225
  });
4229
4226
  }
4230
- #handleStopAgentMessage(message) {}
4227
+ #handleStopAgentMessage(message) {
4228
+ this.#logger.debug({ message }, "received stop agent message");
4229
+ const { sessionId } = message.data;
4230
+ const agent = this.#sessionAgents.get(sessionId);
4231
+ if (!agent) {
4232
+ this.#logger.warn("received stop agent message for unknown session id %s, ignoring", sessionId);
4233
+ return;
4234
+ }
4235
+ agent.stop();
4236
+ this.#sessionTools.delete(sessionId);
4237
+ }
4231
4238
  /**
4232
4239
  * Refreshes the API key by requesting a new token from the SDK server,
4233
4240
  * when the apiKey is a (short lived) token used when runner is deployed
4234
4241
  * using Tool Forge Cloud.
4235
4242
  */
4236
4243
  async #refreshApiKey() {
4237
- const url = new URL(this.#sdkServerUrl);
4238
- url.pathname = "/token/refresh";
4239
- const res = await fetch(url.toString(), {
4244
+ if (!this.#options.tokenProviderEndpoint) return;
4245
+ const res = await fetch(new URL("/token/refresh", this.#options.tokenProviderEndpoint), {
4240
4246
  method: "POST",
4241
4247
  headers: { "Content-Type": "application/json" },
4242
4248
  body: JSON.stringify({ token: this.#apiKey })
@@ -4274,16 +4280,36 @@ var ForgeRunner = class extends EventEmitter {
4274
4280
  //#endregion
4275
4281
  //#region src/cli/actions/start-tool-forge.ts
4276
4282
  async function startToolForge({ configRelPath, debug, mode }) {
4277
- const logger = pino({
4278
- level: debug ? "debug" : "info",
4279
- transport: { target: "pino-pretty" }
4280
- });
4283
+ const logger = pino({ level: debug ? "debug" : "info" });
4281
4284
  try {
4282
4285
  const spinner = ora("loading configuration...").start();
4283
4286
  const { config, configPath } = await getToolForgeConfig(configRelPath);
4284
4287
  spinner.stop();
4285
4288
  logger.debug({ config }, "loaded config from %s", configPath);
4286
- const runner = new ForgeRunner(config, { mode }, logger);
4289
+ const sdkServerUrl = sdkServerUrlSchema.parse(process.env.SDK_SERVER_URL);
4290
+ let apiKey;
4291
+ if (config.apiKey) apiKey = config.apiKey;
4292
+ else {
4293
+ const parsed = z$1.url().safeParse(process.env.TOKEN_PROVIDER_ENDPOINT);
4294
+ if (!parsed.success) throw new Error("either provide apiKey in config, or set the TOKEN_PROVIDER_ENDPOINT");
4295
+ logger.debug("generating token");
4296
+ apiKey = await fetch(new URL("/token/generate", parsed.data), { method: "POST" }).then((res) => res.json()).then((data) => {
4297
+ const parsed$1 = z$1.object({ token: z$1.string() }).safeParse(data);
4298
+ if (!parsed$1.success) throw new Error("invalid token");
4299
+ return parsed$1.data.token;
4300
+ }).catch((error) => {
4301
+ logger.error(error, "error fetching token from TOKEN_PROVIDER_ENDPOINT");
4302
+ throw error;
4303
+ });
4304
+ logger.debug("token generated");
4305
+ }
4306
+ invariant(!!apiKey, "apiKey should be present");
4307
+ const runner = new ForgeRunner({
4308
+ mode,
4309
+ apiKey,
4310
+ sdkServerUrl,
4311
+ toolsDir: config.toolsDir
4312
+ }, logger);
4287
4313
  runner.on("error", async (error) => {
4288
4314
  logger.error(error, "tool runner error - shutting down");
4289
4315
  await runner.stop();
@@ -4335,8 +4361,8 @@ program.command("build").description("build the tools for production").option("-
4335
4361
  const debug = z$1.boolean().optional().default(false).parse(this.opts().debug);
4336
4362
  await build(z$1.string().parse(this.opts().config), debug);
4337
4363
  });
4338
- 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() {
4339
- await login(z$1.string().parse(this.opts().config));
4364
+ program.command("login").description("login to Tool Forge").action(async function() {
4365
+ await login();
4340
4366
  });
4341
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() {
4342
4368
  await deploy(z$1.string().parse(this.opts().config), z$1.boolean().optional().default(false).parse(this.opts().debug));
@@ -6083,24 +6083,18 @@ declare class Block {
6083
6083
  };
6084
6084
  }
6085
6085
  //#endregion
6086
- //#region src/config/config-schema.d.ts
6087
- declare const toolForgeConfigSchema: z$1.ZodIntersection<z$1.ZodIntersection<z$1.ZodObject<{
6088
- toolsDir: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
6089
- apiKey: z$1.ZodOptional<z$1.ZodString>;
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>>;
6093
- appServerUrl: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6094
- appUrl: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodURL>>;
6095
- }, z$1.core.$strip>>, z$1.ZodObject<{
6096
- __tf__tag__name__: z$1.ZodSymbol;
6097
- }, z$1.core.$strip>>;
6098
- type ToolForgeConfig = z$1.infer<typeof toolForgeConfigSchema>;
6099
- //#endregion
6100
6086
  //#region src/internal/forge-runner.d.ts
6101
6087
  type ForgeRunnerOptions = {
6102
6088
  /** Runtime mode for the tool runner. In the development mode, more verbose logging is enabled and tools are automatically reloaded on changes. */
6103
6089
  mode: 'development' | 'production';
6090
+ /** API key */
6091
+ apiKey: string;
6092
+ /** Endpoint to refresh the short term token. If the apiKey is the format of tf_token--****, then ForgeRunner needs to refresh the token before expiration. */
6093
+ tokenProviderEndpoint?: string;
6094
+ /** SDK Server endpoint */
6095
+ sdkServerUrl: string;
6096
+ /** Path to the directory containing tools */
6097
+ toolsDir: string;
6104
6098
  };
6105
6099
  /**
6106
6100
  * ForgeRunner manages the lifecycle of tools or agents, including discovery, loading, and communication with the SDK server.
@@ -6110,7 +6104,7 @@ type ForgeRunnerOptions = {
6110
6104
  */
6111
6105
  declare class ForgeRunner extends EventEmitter {
6112
6106
  #private;
6113
- constructor(config: ToolForgeConfig, options: ForgeRunnerOptions, logger: Logger);
6107
+ constructor(options: ForgeRunnerOptions, logger: Logger);
6114
6108
  get activeSessionsCount(): number;
6115
6109
  stop(): void;
6116
6110
  }
@@ -1,4 +1,4 @@
1
- import { a as AGENT_TAG_NAME, i as AGENT_STEP_TAG_NAME, n as TOOL_TAG_NAME, t as TOOL_HANDLER_TAG_NAME } from "../tool-DDDEH8M3.js";
1
+ import { a as AGENT_TAG_NAME, i as AGENT_STEP_TAG_NAME, n as TOOL_TAG_NAME, t as TOOL_HANDLER_TAG_NAME } from "../tool-BHVNhWPh.js";
2
2
 
3
3
  //#region src/components/tool.ts
4
4
  /**
@@ -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 };
@@ -2915,6 +2915,11 @@ var Agent = class {
2915
2915
  }
2916
2916
  return this.#context;
2917
2917
  }
2918
+ stop() {
2919
+ this.#logger.info("stopping agent...");
2920
+ this.#abortController.abort();
2921
+ this.#logger.info("Agent stopped");
2922
+ }
2918
2923
  async #executeSteps(stepsToExecute) {
2919
2924
  const stepDefinitions = stepsToExecute.filter((stepName) => stepName !== "START" && stepName !== "END").map((stepName) => {
2920
2925
  const stepDef = this.#stepDefinitions[stepName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolforge-js/sdk",
3
- "version": "0.8.4",
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 };