@toolforge-js/sdk 0.1.0 → 0.2.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.
- package/README.md +79 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Tool Forge SDK
|
|
2
|
+
|
|
3
|
+
Backend code to complete tools, instantly.
|
|
4
|
+
|
|
5
|
+
Tool Forge SDK provides the necessary backend functionalities to build and run tools seamlessly. It abstracts away the complexities of backend development, allowing developers to focus on writing code while Tool Forge SDK handles the rest.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Prerequisites
|
|
10
|
+
|
|
11
|
+
- tool-forge sdk uses [bun](https://bun.sh) runtime, so you need to install `bun`
|
|
12
|
+
|
|
13
|
+
### Installation Steps
|
|
14
|
+
|
|
15
|
+
You can install the tool-forge sdk package using `bun` by running the following command in your terminal:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
bun add @toolforge-js/sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This command will add the tool-forge sdk package to your project's dependencies, allowing you to utilize its features in your backend development.
|
|
22
|
+
|
|
23
|
+
### Getting Authentication Credentials
|
|
24
|
+
|
|
25
|
+
To use tool-forge sdk, you need to obtain authentication credentials. Follow these steps:
|
|
26
|
+
|
|
27
|
+
1. Sign up or log in to your Tool Forge account.
|
|
28
|
+
2. Create a new workspace or select an existing one.
|
|
29
|
+
3. Create a new environment within the workspace or select an existing one.
|
|
30
|
+
4. Generate a new API key for that environment.
|
|
31
|
+
5. Store these credentials securely, as you will need them to authenticate your requests when using the SDK.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Setting Up the SDK
|
|
36
|
+
|
|
37
|
+
After installing the tool-forge sdk, you have configure the SDK using `toolforge.config.ts`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// toolforge.config.ts
|
|
41
|
+
import { defineToolForgeConfig } from '@toolforge-js/sdk'
|
|
42
|
+
import 'dotenv/config'
|
|
43
|
+
import { defineConfig } from '@toolforge-js/sdk/config'
|
|
44
|
+
import * as z from 'zod'
|
|
45
|
+
|
|
46
|
+
// store the API key in environment variable TOOL_FORGE_API_KEY
|
|
47
|
+
|
|
48
|
+
const { TOOL_FORGE_API_KEY } = z
|
|
49
|
+
.object({
|
|
50
|
+
TOOL_FORGE_API_KEY: z
|
|
51
|
+
.string()
|
|
52
|
+
.refine((val) => val.startsWith('sk_live') || val.startsWith('pk_test'), {
|
|
53
|
+
message: 'API key must start with sk_live or pk_test',
|
|
54
|
+
}),
|
|
55
|
+
})
|
|
56
|
+
.parse(process.env)
|
|
57
|
+
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
apiKey: TOOL_FORGE_API_KEY,
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Writing a Tool
|
|
64
|
+
|
|
65
|
+
After installing the tool-forge sdk package, you can start using it in your backend code. Here's a simple example to get you started:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// tools/my-first-tool.ts
|
|
69
|
+
import { defineTool } from '@toolforge-js/sdk'
|
|
70
|
+
|
|
71
|
+
export default defineTool({
|
|
72
|
+
name: 'My First Tool',
|
|
73
|
+
description: 'A simple tool using Tool Forge SDK',
|
|
74
|
+
async run({ io }) {
|
|
75
|
+
const name = await io.textInput({ label: 'Enter your name' })
|
|
76
|
+
return `Hello, ${name}!`
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toolforge-js/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./components": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@toolforge-js/config": "workspace:*",
|
|
35
|
-
"@types/bun": "1.
|
|
35
|
+
"@types/bun": "1.3.1",
|
|
36
36
|
"@types/node": "24.0.7",
|
|
37
37
|
"commander": "14.0.1",
|
|
38
38
|
"eslint": "9.24.0",
|