@toolforge-js/sdk 0.7.0 → 0.8.2

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.
@@ -1,4 +1,4 @@
1
- import { a as TOOL_TAG_NAME, i as TOOL_HANDLER_TAG_NAME, n as AGENT_TAG_NAME, t as AGENT_STEP_TAG_NAME } from "../agent-DBDnKm26.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-DDDEH8M3.js";
2
2
 
3
3
  //#region src/components/tool.ts
4
4
  /**
@@ -10,6 +10,10 @@ type ToolForgeConfig = {
10
10
  apiKey: string;
11
11
  /** Optional URL for the SDK server (overrides default). */
12
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;
13
17
  };
14
18
  /**
15
19
  * Define and validate Tool Forge SDK configuration.
@@ -20,7 +24,10 @@ declare function defineConfig(input: ToolForgeConfig): {
20
24
  toolsDir: string;
21
25
  apiKey: string;
22
26
  sdkServer: string;
27
+ appServerUrl: string;
28
+ appUrl: string;
23
29
  maxRetries: number;
30
+ __tf__tag__name__: symbol;
24
31
  };
25
32
  //#endregion
26
33
  export { defineConfig };
@@ -1,4 +1,4 @@
1
- import { t as toolForgeConfigSchema } from "../config-schema-CcWOtgOv.js";
1
+ import { n as toolForgeConfigSchema, t as TF_CONFIG_TAG_NAME } from "../config-schema-DcLVggqh.js";
2
2
 
3
3
  //#region src/config/index.ts
4
4
  /**
@@ -7,7 +7,10 @@ import { t as toolForgeConfigSchema } from "../config-schema-CcWOtgOv.js";
7
7
  * @param config - The configuration object for Tool Forge SDK.
8
8
  */
9
9
  function defineConfig(input) {
10
- return toolForgeConfigSchema.parse(input);
10
+ return {
11
+ __tf__tag__name__: TF_CONFIG_TAG_NAME,
12
+ ...toolForgeConfigSchema.parse(input)
13
+ };
11
14
  }
12
15
 
13
16
  //#endregion
@@ -0,0 +1,19 @@
1
+ import * as z$1 from "zod";
2
+
3
+ //#region ../core/dist/token/index.js
4
+ const TOKEN_PREFIX = "tf_token--";
5
+
6
+ //#endregion
7
+ //#region src/config/config-schema.ts
8
+ const toolForgeConfigSchema = z$1.object({
9
+ toolsDir: z$1.string().describe("Directory where the tools are located").optional().default("tools"),
10
+ apiKey: z$1.string().describe("API key for authenticating with the Tool Forge platform").refine((val) => val.startsWith("sk_live") || val.startsWith("pk_test") || val.startsWith(TOKEN_PREFIX), { message: `API key must start with sk_live, pk_test or ${TOKEN_PREFIX}` }).describe("API key for authenticating with the Tool Forge platform."),
11
+ sdkServer: z$1.url().describe("URL of the Tool Forge SDK server").optional().default("https://sdk.tool-forge.ai"),
12
+ appServerUrl: z$1.url().optional().describe("URL of the Tool Forge application server").default("https://api.tool-forge.ai"),
13
+ appUrl: z$1.url().optional().describe("URL of the Tool Forge application").default("https://app.tool-forge.ai"),
14
+ maxRetries: z$1.number().optional().default(100)
15
+ });
16
+ const TF_CONFIG_TAG_NAME = Symbol("TOOL_FORGE_CONFIG");
17
+
18
+ //#endregion
19
+ export { toolForgeConfigSchema as n, TOKEN_PREFIX as r, TF_CONFIG_TAG_NAME as t };
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
2
  import * as z$1 from "zod";
3
+ import { nanoid } from "nanoid";
3
4
  import { P, match } from "ts-pattern";
4
5
  import { setTimeout } from "node:timers/promises";
5
- import { nanoid } from "nanoid";
6
6
 
7
7
  //#region rolldown:runtime
8
8
  var __create = Object.create;
@@ -30,6 +30,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  }) : target, mod));
31
31
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
32
32
 
33
+ //#endregion
34
+ //#region src/lib/utils.ts
35
+ function convertToWords(input) {
36
+ if (input.includes("-") || input.includes("_")) return input.split(/[-_]+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
37
+ return input.split(/(?=[A-Z])/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
38
+ }
39
+ function invariant(cond, message) {
40
+ if (!cond) throw new Error(message);
41
+ }
42
+ function getErrorMessage(error, defaultMessage = "Something went wrong. Please try again") {
43
+ let errorMessage = defaultMessage;
44
+ if (error instanceof z$1.ZodError) errorMessage = error.issues.length ? error.issues.map((e) => e.message).join(", ") : error.message;
45
+ else if (error instanceof Error) errorMessage = error.message;
46
+ return errorMessage;
47
+ }
48
+
33
49
  //#endregion
34
50
  //#region ../../node_modules/.bun/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js
35
51
  var require_dayjs_min = /* @__PURE__ */ __commonJS({ "../../node_modules/.bun/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js": ((exports, module) => {
@@ -1234,9 +1250,24 @@ const layoutBlockSchema = z$1.object({
1234
1250
  columns: z$1.number().optional().default(12),
1235
1251
  children: layoutChildren.array()
1236
1252
  });
1253
+ const timelineBlockSchema = z$1.object({
1254
+ type: z$1.literal("timeline"),
1255
+ items: z$1.array(z$1.object({
1256
+ title: z$1.string().optional(),
1257
+ content: z$1.string()
1258
+ })),
1259
+ orientation: z$1.enum(["horizontal", "vertical"]).optional().default("vertical"),
1260
+ mode: z$1.enum([
1261
+ "start",
1262
+ "end",
1263
+ "alternate"
1264
+ ]).optional().default("start"),
1265
+ reverse: z$1.boolean().optional().default(false)
1266
+ });
1237
1267
  const blockSchema = z$1.discriminatedUnion("type", [
1238
1268
  kpiCardSchema,
1239
1269
  chartBlock,
1270
+ timelineBlockSchema,
1240
1271
  layoutBlockSchema,
1241
1272
  tableBlockSchema,
1242
1273
  imageBlockSchema,
@@ -1420,7 +1451,12 @@ const runnerId = z$1.string().regex(/^tf-runner:[A-Za-z0-9_-]{32}$/, { message:
1420
1451
  const clientId = z$1.string().regex(/^tf-client:[A-Za-z0-9_-]{32}$/, { message: "runnerId must start with \"tf-runner:\" followed by a 32-character nanoid" });
1421
1452
  const sdkServerId = z$1.string().regex(/^tf-ss:[A-Za-z0-9_-]{32}$/, { message: "serverId must start with \"tf-ss:\" followed by a 32-character nanoid" });
1422
1453
  const appServerId = z$1.string().regex(/^tf-as:[A-Za-z0-9_-]{32}$/, { message: "serverId must start with \"tf-ss:\" followed by a 32-character nanoid" });
1423
- const serverId = z$1.union([sdkServerId, appServerId]);
1454
+ const ciServerId = z$1.string().regex(/^tf-cs:[A-Za-z0-9_-]{32}$/, { message: "serverId must start with \"tf-cs:\" followed by a 32-character nanoid" });
1455
+ const serverId = z$1.union([
1456
+ sdkServerId,
1457
+ appServerId,
1458
+ ciServerId
1459
+ ]);
1424
1460
  const ackMessageSchema = baseMessageSchema.extend({
1425
1461
  type: z$1.literal("ACK"),
1426
1462
  rootMessageId: z$1.string(),
@@ -1770,6 +1806,26 @@ const agentErrorMessageSchema = baseMessageSchema.extend({
1770
1806
  executionContext: executionContextSchema
1771
1807
  })
1772
1808
  });
1809
+ const inviteEmailMessageSchema = baseMessageSchema.extend({
1810
+ type: z$1.literal("invite-email"),
1811
+ payload: z$1.object({
1812
+ email: z$1.email(),
1813
+ inviteLink: z$1.url(),
1814
+ role: z$1.string(),
1815
+ inviterEmail: z$1.string(),
1816
+ inviterName: z$1.string(),
1817
+ workspaceName: z$1.string()
1818
+ })
1819
+ });
1820
+ const deployForgeMessageSchema = baseMessageSchema.extend({
1821
+ type: z$1.literal("deploy-forge"),
1822
+ payload: z$1.object({
1823
+ deploymentId: z$1.uuid(),
1824
+ environmentId: z$1.uuid(),
1825
+ workspaceId: z$1.string(),
1826
+ sha256: z$1.string().min(64).max(64)
1827
+ })
1828
+ });
1773
1829
 
1774
1830
  //#endregion
1775
1831
  //#region src/internal/block.ts
@@ -2000,6 +2056,17 @@ var Block = class {
2000
2056
  ...props
2001
2057
  });
2002
2058
  }
2059
+ /**
2060
+ * Creates a timeline block.
2061
+ *
2062
+ * A timeline block displays a sequence of events in chronological order.
2063
+ */
2064
+ timeline(props) {
2065
+ return timelineBlockSchema.parse({
2066
+ type: "timeline",
2067
+ ...props
2068
+ });
2069
+ }
2003
2070
  };
2004
2071
 
2005
2072
  //#endregion
@@ -2027,22 +2094,6 @@ function runWithRetries(fn, retries = 3, config = {}) {
2027
2094
  return execute();
2028
2095
  }
2029
2096
 
2030
- //#endregion
2031
- //#region src/lib/utils.ts
2032
- function convertToWords(input) {
2033
- if (input.includes("-") || input.includes("_")) return input.split(/[-_]+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
2034
- return input.split(/(?=[A-Z])/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
2035
- }
2036
- function invariant(cond, message) {
2037
- if (!cond) throw new Error(message);
2038
- }
2039
- function getErrorMessage(error, defaultMessage = "Something went wrong. Please try again") {
2040
- let errorMessage = defaultMessage;
2041
- if (error instanceof z$1.ZodError) errorMessage = error.issues.length ? error.issues.map((e) => e.message).join(", ") : error.message;
2042
- else if (error instanceof Error) errorMessage = error.message;
2043
- return errorMessage;
2044
- }
2045
-
2046
2097
  //#endregion
2047
2098
  //#region src/internal/loader.ts
2048
2099
  var Loader = class {
@@ -2384,7 +2435,7 @@ var IO = class {
2384
2435
  /**
2385
2436
  * Prompts the user for a text input.
2386
2437
  */
2387
- async textInput({ label, description, optional, secure, inputType, mode, maxRetryAttempts = 5, validationSchema, defaultValue }) {
2438
+ async textInput({ label, description, optional, secure, inputType, mode, min, max, maxRetryAttempts = 5, validationSchema, defaultValue }) {
2388
2439
  const form = { value: {
2389
2440
  type: "text",
2390
2441
  label,
@@ -2392,6 +2443,8 @@ var IO = class {
2392
2443
  optional,
2393
2444
  secure,
2394
2445
  mode,
2446
+ min,
2447
+ max,
2395
2448
  inputType
2396
2449
  } };
2397
2450
  const stringValidationSchema = validationSchema ?? getValidationSchemaForField(form.value);
@@ -2624,73 +2677,6 @@ var IO = class {
2624
2677
  }
2625
2678
  };
2626
2679
 
2627
- //#endregion
2628
- //#region src/internal/tool.ts
2629
- const TOOL_HANDLER_TAG_NAME = Symbol("TOOL_HANDLER");
2630
- const TOOL_TAG_NAME = Symbol("TOOL");
2631
- /**
2632
- * Tool class is responsible for running the tool's logic.
2633
- * It manages the tool lifecycle, communication with the worker, and handles sending messages back to the ForgeRunner.
2634
- * It uses the IO component to facilitate input/output operations for the tool.
2635
- */
2636
- var Tool = class {
2637
- #metadata;
2638
- #abortController = new AbortController();
2639
- #handler;
2640
- #io;
2641
- #block;
2642
- #logger;
2643
- constructor(options, logger) {
2644
- this.#metadata = options.metadata;
2645
- this.#handler = options.handler;
2646
- this.#logger = logger.child({
2647
- sessionId: this.#metadata.sessionId,
2648
- component: "TOOL"
2649
- });
2650
- this.#io = new IO({
2651
- sessionId: this.#metadata.sessionId,
2652
- runnerId: this.#metadata.runnerId,
2653
- webSocketClient: options.webSocketClient,
2654
- signal: this.#abortController.signal,
2655
- executionContext: { type: "TOOL" }
2656
- }, this.#logger);
2657
- this.#block = new Block({ signal: this.#abortController.signal });
2658
- this.#logger.debug("initialized Tool instance");
2659
- }
2660
- async run() {
2661
- return new Promise(async (resolve, reject) => {
2662
- if (this.#abortController.signal.aborted) {
2663
- this.#logger.info("tool execution aborted before start");
2664
- return Promise.reject(/* @__PURE__ */ new Error("tool execution aborted"));
2665
- }
2666
- this.#abortController.signal.addEventListener("abort", () => {
2667
- this.#logger.info("tool execution aborted");
2668
- reject(/* @__PURE__ */ new Error("Tool execution aborted"));
2669
- });
2670
- try {
2671
- this.#logger.info("running tool handler...");
2672
- const output = await this.#handler({
2673
- io: this.#io,
2674
- signal: this.#abortController.signal,
2675
- block: this.#block,
2676
- metadata: this.#metadata
2677
- });
2678
- this.#logger.info("tool handler completed successfully");
2679
- this.#io[STOP_SYMBOL]();
2680
- resolve(output);
2681
- } catch (error) {
2682
- this.#logger.error(error, "error running tool handler");
2683
- return reject(error);
2684
- }
2685
- });
2686
- }
2687
- stop() {
2688
- this.#logger.info("stopping Tool...");
2689
- this.#abortController.abort();
2690
- this.#logger.info("Tool stopped");
2691
- }
2692
- };
2693
-
2694
2680
  //#endregion
2695
2681
  //#region src/internal/workflow-builder.ts
2696
2682
  var WorkflowBuilder = class {
@@ -3090,4 +3076,71 @@ var Agent = class {
3090
3076
  };
3091
3077
 
3092
3078
  //#endregion
3093
- export { __toESM as C, __require as S, startAgentMessageSchema as _, TOOL_TAG_NAME as a, stopToolMessageSchema as b, getErrorMessage as c, runWithRetries as d, ackMessageSchema as f, runnerId as g, initCommunicationMessageSchema as h, TOOL_HANDLER_TAG_NAME as i, invariant as l, heartbeatAckMessageSchema as m, AGENT_TAG_NAME as n, Tool as o, baseMessageSchema as p, Agent as r, convertToWords as s, AGENT_STEP_TAG_NAME as t, exponentialBackoff as u, startToolMessageSchema as v, __commonJS as x, stopAgentMessageSchema as y };
3079
+ //#region src/internal/tool.ts
3080
+ const TOOL_HANDLER_TAG_NAME = Symbol("TOOL_HANDLER");
3081
+ const TOOL_TAG_NAME = Symbol("TOOL");
3082
+ /**
3083
+ * Tool class is responsible for running the tool's logic.
3084
+ * It manages the tool lifecycle, communication with the worker, and handles sending messages back to the ForgeRunner.
3085
+ * It uses the IO component to facilitate input/output operations for the tool.
3086
+ */
3087
+ var Tool = class {
3088
+ #metadata;
3089
+ #abortController = new AbortController();
3090
+ #handler;
3091
+ #io;
3092
+ #block;
3093
+ #logger;
3094
+ constructor(options, logger) {
3095
+ this.#metadata = options.metadata;
3096
+ this.#handler = options.handler;
3097
+ this.#logger = logger.child({
3098
+ sessionId: this.#metadata.sessionId,
3099
+ component: "TOOL"
3100
+ });
3101
+ this.#io = new IO({
3102
+ sessionId: this.#metadata.sessionId,
3103
+ runnerId: this.#metadata.runnerId,
3104
+ webSocketClient: options.webSocketClient,
3105
+ signal: this.#abortController.signal,
3106
+ executionContext: { type: "TOOL" }
3107
+ }, this.#logger);
3108
+ this.#block = new Block({ signal: this.#abortController.signal });
3109
+ this.#logger.debug("initialized Tool instance");
3110
+ }
3111
+ async run() {
3112
+ return new Promise(async (resolve, reject) => {
3113
+ if (this.#abortController.signal.aborted) {
3114
+ this.#logger.info("tool execution aborted before start");
3115
+ return Promise.reject(/* @__PURE__ */ new Error("tool execution aborted"));
3116
+ }
3117
+ this.#abortController.signal.addEventListener("abort", () => {
3118
+ this.#logger.info("tool execution aborted");
3119
+ reject(/* @__PURE__ */ new Error("Tool execution aborted"));
3120
+ });
3121
+ try {
3122
+ this.#logger.info("running tool handler...");
3123
+ const output = await this.#handler({
3124
+ io: this.#io,
3125
+ signal: this.#abortController.signal,
3126
+ block: this.#block,
3127
+ metadata: this.#metadata
3128
+ });
3129
+ this.#logger.info("tool handler completed successfully");
3130
+ this.#io[STOP_SYMBOL]();
3131
+ resolve(output);
3132
+ } catch (error) {
3133
+ this.#logger.error(error, "error running tool handler");
3134
+ return reject(error);
3135
+ }
3136
+ });
3137
+ }
3138
+ stop() {
3139
+ this.#logger.info("stopping Tool...");
3140
+ this.#abortController.abort();
3141
+ this.#logger.info("Tool stopped");
3142
+ }
3143
+ };
3144
+
3145
+ //#endregion
3146
+ export { __toESM as C, __require as S, stopToolMessageSchema as _, AGENT_TAG_NAME as a, invariant as b, runWithRetries as c, heartbeatAckMessageSchema as d, initCommunicationMessageSchema as f, stopAgentMessageSchema as g, startToolMessageSchema as h, AGENT_STEP_TAG_NAME as i, ackMessageSchema as l, startAgentMessageSchema as m, TOOL_TAG_NAME as n, Agent as o, runnerId as p, Tool as r, exponentialBackoff as s, TOOL_HANDLER_TAG_NAME as t, baseMessageSchema as u, convertToWords as v, __commonJS as x, getErrorMessage as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolforge-js/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -17,23 +17,29 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
+ "@clack/prompts": "0.11.0",
21
+ "better-auth": "1.3.34",
22
+ "bumpp": "10.4.0",
20
23
  "chokidar": "4.0.3",
21
24
  "es-toolkit": "1.39.10",
22
25
  "esbuild": "0.27.0",
26
+ "hono": "4.9.7",
23
27
  "nanoid": "5.1.5",
28
+ "ora": "9.0.0",
24
29
  "picocolors": "1.1.1",
25
30
  "pino": "9.11.0",
26
31
  "pino-pretty": "13.1.1",
32
+ "tar": "7.5.2",
27
33
  "ts-pattern": "5.8.0",
28
34
  "zod": "4.1.12"
29
35
  },
30
36
  "devDependencies": {
31
- "@types/bun": "1.3.1",
32
- "@types/node": "24.0.7",
37
+ "@types/bun": "1.3.3",
38
+ "@types/node": "24.10.0",
33
39
  "commander": "14.0.2",
34
- "typescript": "5.9.2"
40
+ "typescript": "5.9.3"
35
41
  },
36
42
  "bin": {
37
- "toolforge-js": "index.js"
43
+ "toolforge": "index.js"
38
44
  }
39
45
  }
@@ -1,12 +0,0 @@
1
- import * as z$1 from "zod";
2
-
3
- //#region src/config/config-schema.ts
4
- const toolForgeConfigSchema = z$1.object({
5
- toolsDir: z$1.string().optional().default("tools"),
6
- apiKey: z$1.string().refine((val) => val.startsWith("sk_live") || val.startsWith("pk_test"), { message: "API key must start with sk_live or pk_test" }).describe("API key for authenticating with the Tool Forge platform."),
7
- sdkServer: z$1.url().optional().default("https://sdk.tool-forge.ai"),
8
- maxRetries: z$1.number().optional().default(100)
9
- });
10
-
11
- //#endregion
12
- export { toolForgeConfigSchema as t };