@toolforge-js/sdk 0.8.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 AGENT_TAG_NAME, i as AGENT_STEP_TAG_NAME, n as TOOL_TAG_NAME, t as TOOL_HANDLER_TAG_NAME } from "../tool-UVAGtnlr.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,47 +1806,26 @@ const agentErrorMessageSchema = baseMessageSchema.extend({
1770
1806
  executionContext: executionContextSchema
1771
1807
  })
1772
1808
  });
1773
-
1774
- //#endregion
1775
- //#region ../core/dist/utils.js
1776
- function exponentialBackoff(attempt, initialDelay = 1e3, maxRetryDelay = 3e4, jitterFactor = .5, backoffMultiplier = 2) {
1777
- let delay = initialDelay * Math.pow(backoffMultiplier, attempt - 1);
1778
- const jitter = delay * jitterFactor * Math.random();
1779
- delay += jitter;
1780
- return Math.min(delay, maxRetryDelay);
1781
- }
1782
- function runWithRetries(fn, retries = 3, config = {}) {
1783
- let attempt = 0;
1784
- const execute = async () => {
1785
- try {
1786
- return await fn();
1787
- } catch (error) {
1788
- if (attempt < retries) {
1789
- attempt++;
1790
- await setTimeout(exponentialBackoff(attempt, config.initialDelayMs, config.maxDelayMs, config.backoffMultiplier));
1791
- return execute();
1792
- }
1793
- throw error;
1794
- }
1795
- };
1796
- return execute();
1797
- }
1798
-
1799
- //#endregion
1800
- //#region src/lib/utils.ts
1801
- function convertToWords(input) {
1802
- if (input.includes("-") || input.includes("_")) return input.split(/[-_]+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
1803
- return input.split(/(?=[A-Z])/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
1804
- }
1805
- function invariant(cond, message) {
1806
- if (!cond) throw new Error(message);
1807
- }
1808
- function getErrorMessage(error, defaultMessage = "Something went wrong. Please try again") {
1809
- let errorMessage = defaultMessage;
1810
- if (error instanceof z$1.ZodError) errorMessage = error.issues.length ? error.issues.map((e) => e.message).join(", ") : error.message;
1811
- else if (error instanceof Error) errorMessage = error.message;
1812
- return errorMessage;
1813
- }
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
+ });
1814
1829
 
1815
1830
  //#endregion
1816
1831
  //#region src/internal/block.ts
@@ -2041,8 +2056,44 @@ var Block = class {
2041
2056
  ...props
2042
2057
  });
2043
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
+ }
2044
2070
  };
2045
2071
 
2072
+ //#endregion
2073
+ //#region ../core/dist/utils.js
2074
+ function exponentialBackoff(attempt, initialDelay = 1e3, maxRetryDelay = 3e4, jitterFactor = .5, backoffMultiplier = 2) {
2075
+ let delay = initialDelay * Math.pow(backoffMultiplier, attempt - 1);
2076
+ const jitter = delay * jitterFactor * Math.random();
2077
+ delay += jitter;
2078
+ return Math.min(delay, maxRetryDelay);
2079
+ }
2080
+ function runWithRetries(fn, retries = 3, config = {}) {
2081
+ let attempt = 0;
2082
+ const execute = async () => {
2083
+ try {
2084
+ return await fn();
2085
+ } catch (error) {
2086
+ if (attempt < retries) {
2087
+ attempt++;
2088
+ await setTimeout(exponentialBackoff(attempt, config.initialDelayMs, config.maxDelayMs, config.backoffMultiplier));
2089
+ return execute();
2090
+ }
2091
+ throw error;
2092
+ }
2093
+ };
2094
+ return execute();
2095
+ }
2096
+
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);
@@ -3090,4 +3143,4 @@ var Tool = class {
3090
3143
  };
3091
3144
 
3092
3145
  //#endregion
3093
- export { __toESM as C, __require as S, startAgentMessageSchema as _, AGENT_TAG_NAME as a, stopToolMessageSchema as b, getErrorMessage as c, runWithRetries as d, ackMessageSchema as f, runnerId as g, initCommunicationMessageSchema as h, AGENT_STEP_TAG_NAME as i, invariant as l, heartbeatAckMessageSchema as m, TOOL_TAG_NAME as n, Agent as o, baseMessageSchema as p, Tool as r, convertToWords as s, TOOL_HANDLER_TAG_NAME as t, exponentialBackoff as u, startToolMessageSchema as v, __commonJS as x, stopAgentMessageSchema as y };
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.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -17,22 +17,27 @@
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",
24
28
  "ora": "9.0.0",
25
29
  "picocolors": "1.1.1",
26
30
  "pino": "9.11.0",
27
31
  "pino-pretty": "13.1.1",
32
+ "tar": "7.5.2",
28
33
  "ts-pattern": "5.8.0",
29
34
  "zod": "4.1.12"
30
35
  },
31
36
  "devDependencies": {
32
- "@types/bun": "1.3.1",
33
- "@types/node": "24.0.7",
37
+ "@types/bun": "1.3.3",
38
+ "@types/node": "24.10.0",
34
39
  "commander": "14.0.2",
35
- "typescript": "5.9.2"
40
+ "typescript": "5.9.3"
36
41
  },
37
42
  "bin": {
38
43
  "toolforge": "index.js"
@@ -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 };