@toolforge-js/sdk 0.2.0 → 0.4.0

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.
@@ -0,0 +1,33 @@
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";
2
+
3
+ //#region src/components/tool.ts
4
+ /**
5
+ * Defines a tool.
6
+ */
7
+ function defineTool(options) {
8
+ if (!options.name) throw new Error("Tool must have a name");
9
+ if (typeof options.handler !== "function") throw new Error("Tool must have a handler function");
10
+ options.handler.__tf__tag__name__ = TOOL_HANDLER_TAG_NAME;
11
+ return {
12
+ __tf__tag__name__: TOOL_TAG_NAME,
13
+ name: options.name,
14
+ description: options.description,
15
+ handler: options.handler
16
+ };
17
+ }
18
+
19
+ //#endregion
20
+ //#region src/components/agent.ts
21
+ function defineAgent(definition) {
22
+ return {
23
+ __tf__tag__name__: AGENT_TAG_NAME,
24
+ ...definition,
25
+ steps: Object.fromEntries(Object.entries(definition.steps).map(([key, step]) => [key, {
26
+ ...step,
27
+ __tf__tag__name__: AGENT_STEP_TAG_NAME
28
+ }]))
29
+ };
30
+ }
31
+
32
+ //#endregion
33
+ export { defineAgent, defineTool };
@@ -0,0 +1,26 @@
1
+ //#region src/config/index.d.ts
2
+ type ToolForgeConfig = {
3
+ /** Optional path to the directory containing tools. */
4
+ toolsDir?: string;
5
+ /**
6
+ * API key for authenticating with the Tool Forge platform.
7
+ * Must start with `sk_live` or `pk_test`.
8
+ * Get your API key from the Tool Forge environment dashboard.
9
+ */
10
+ apiKey: string;
11
+ /** Optional URL for the SDK server (overrides default). */
12
+ sdkServer?: string;
13
+ };
14
+ /**
15
+ * Define and validate Tool Forge SDK configuration.
16
+ *
17
+ * @param config - The configuration object for Tool Forge SDK.
18
+ */
19
+ declare function defineConfig(input: ToolForgeConfig): {
20
+ toolsDir: string;
21
+ apiKey: string;
22
+ sdkServer: string;
23
+ maxRetries: number;
24
+ };
25
+ //#endregion
26
+ export { defineConfig };
@@ -0,0 +1,14 @@
1
+ import { t as toolForgeConfigSchema } from "../config-schema-CcWOtgOv.js";
2
+
3
+ //#region src/config/index.ts
4
+ /**
5
+ * Define and validate Tool Forge SDK configuration.
6
+ *
7
+ * @param config - The configuration object for Tool Forge SDK.
8
+ */
9
+ function defineConfig(input) {
10
+ return toolForgeConfigSchema.parse(input);
11
+ }
12
+
13
+ //#endregion
14
+ export { defineConfig };
@@ -0,0 +1,12 @@
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 };
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@toolforge-js/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
+ "files": [
6
+ "dist",
7
+ "index.js"
8
+ ],
5
9
  "exports": {
6
10
  "./components": {
7
11
  "types": "./dist/components/index.d.ts",
@@ -12,15 +16,7 @@
12
16
  "import": "./dist/config/index.js"
13
17
  }
14
18
  },
15
- "scripts": {
16
- "build": "tsdown",
17
- "lint": "eslint --fix --cache .",
18
- "format": "prettier --write --cache --ignore-path .gitignore --ignore-path ../../.gitignore .",
19
- "typecheck": "tsc",
20
- "typecheck:watch": "tsc --watch"
21
- },
22
19
  "dependencies": {
23
- "@toolforge-js/core": "workspace:*",
24
20
  "chokidar": "4.0.3",
25
21
  "es-toolkit": "1.39.10",
26
22
  "nanoid": "5.1.5",
@@ -31,16 +27,12 @@
31
27
  "zod": "4.1.12"
32
28
  },
33
29
  "devDependencies": {
34
- "@toolforge-js/config": "workspace:*",
35
30
  "@types/bun": "1.3.1",
36
31
  "@types/node": "24.0.7",
37
- "commander": "14.0.1",
38
- "eslint": "9.24.0",
39
- "prettier": "3.5.3",
40
- "tsdown": "0.15.9",
32
+ "commander": "14.0.2",
41
33
  "typescript": "5.9.2"
42
34
  },
43
35
  "bin": {
44
- "tool-forge-sdk": "index.js"
36
+ "toolforge-js": "index.js"
45
37
  }
46
- }
38
+ }
package/eslint.config.js DELETED
@@ -1 +0,0 @@
1
- export { default } from '@toolforge-js/config/eslint.config.js'
@@ -1 +0,0 @@
1
- export { default } from '@toolforge-js/config/prettier.config.js'
package/tsconfig.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@toolforge-js/config/base.json"
3
- }
package/tsdown.config.ts DELETED
@@ -1,51 +0,0 @@
1
- import * as fs from 'node:fs/promises'
2
- import * as path from 'node:path'
3
- import { fileURLToPath } from 'node:url'
4
-
5
- import { defineConfig } from 'tsdown'
6
- import * as z from 'zod'
7
-
8
- export default defineConfig({
9
- entry: ['src/components/index.ts', 'src/config/index.ts', 'src/cli/index.ts'],
10
- format: ['esm'],
11
- sourcemap: false,
12
- clean: true,
13
- dts: {
14
- resolve: ['@toolforge-js/core/schema', '@toolforge-js/core/utils'],
15
- },
16
- noExternal: ['@toolforge-js/core/schema', '@toolforge-js/core/utils'],
17
- onSuccess: async () => {
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
19
- const packageJsonPath = path.resolve(__dirname, '../core', 'package.json')
20
- const packageJsonContent = z
21
- .object({
22
- exports: z.record(
23
- z.string(),
24
- z.object({ types: z.string(), default: z.string() }),
25
- ),
26
- })
27
- .loose()
28
- .parse(JSON.parse(await fs.readFile(packageJsonPath, 'utf-8')))
29
- for (const [key, value] of Object.entries(packageJsonContent.exports)) {
30
- const updatedValue = {
31
- ...value,
32
- types: changeDtsToTypePath(value.types),
33
- default: changeEsmToDefaultPath(value.default),
34
- }
35
- packageJsonContent.exports[key] = updatedValue
36
- }
37
- await fs.writeFile(
38
- packageJsonPath,
39
- JSON.stringify(packageJsonContent, null, 2),
40
- 'utf-8',
41
- )
42
- },
43
- })
44
-
45
- function changeDtsToTypePath(typePath: string) {
46
- return typePath.replace('dist', 'src').replace(/\.d\.ts$/, '.ts')
47
- }
48
-
49
- function changeEsmToDefaultPath(defaultPath: string) {
50
- return defaultPath.replace('dist', 'src').replace(/\.js$/, '.ts')
51
- }