Skip to content

Commit 2062ada

Browse files
authored
Generate Fern TypeSscript SDK (#3785)
1 parent d55b963 commit 2062ada

File tree

239 files changed

+14550
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+14550
-3
lines changed

fern/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.preview

fern/credentials/introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subtitle: Never send your credentials to LLMs.
44
slug: credentials/introduction
55
---
66

7-
Need to give Skyvern access to your credentials? Usernames and passwords, 2FA, credit cards for payments, etc. Skyvern's credential management provides a secure way to manage and use credentials. Agents can then without exposing those credentials to LLMs.
7+
Need to give Skyvern access to your credentials? Usernames and passwords, 2FA, credit cards for payments, etc. Skyvern's credential management provides a secure way to manage and use credentials. Agents can then use them without exposing those credentials to LLMs.
88

99
### 2FA Support (TOTP)
1010

fern/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ navigation:
158158
- api: API Reference
159159
snippets:
160160
python: skyvern
161+
typescript: "@skyvern/client"
161162
layout:
162163
- section: Agent
163164
contents:

fern/fern.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"organization": "skyvern",
3-
"version": "0.63.26"
3+
"version": "0.94.3"
44
}

fern/generators.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ groups:
1717
generators:
1818
- name: fernapi/fern-python-sdk
1919
smart-casing: true
20-
version: 4.3.17
20+
version: 4.31.1
2121
output:
2222
location: pypi
2323
package-name: skyvern
2424
github:
2525
repository: Skyvern-AI/skyvern-python
2626
config:
2727
client_class_name: Skyvern
28+
ts-sdk:
29+
generators:
30+
- name: fernapi/fern-typescript-sdk
31+
version: 3.11.1
32+
output:
33+
location: npm
34+
package-name: "@skyvern/client"
35+
github:
36+
repository: Skyvern-AI/skyvern-typescript
37+
config:
38+
namespaceExport: Skyvern

scripts/fern_build_python_sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
fern generate --group python-sdk --log-level debug --preview
4+
cp -rf fern/.preview/fern-python-sdk/src/skyvern/* skyvern/client/

scripts/fern_build_ts_sdk.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
fern generate --group ts-sdk --log-level debug --preview
4+
cp -rf fern/.preview/fern-typescript-sdk/* skyvern-ts/client/

skyvern-ts/client/README.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Skyvern TypeScript Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FSkyvern-AI%2Fskyvern-typescript)
4+
[![npm shield](https://img.shields.io/npm/v/@skyvern/client)](https://www.npmjs.com/package/@skyvern/client)
5+
6+
The Skyvern TypeScript library provides convenient access to the Skyvern APIs from TypeScript.
7+
8+
## Installation
9+
10+
```sh
11+
npm i -s @skyvern/client
12+
```
13+
14+
## Reference
15+
16+
A full reference for this library is available [here](https://github.com/Skyvern-AI/skyvern-typescript/blob/HEAD/./reference.md).
17+
18+
## Usage
19+
20+
Instantiate and use the client with the following:
21+
22+
```typescript
23+
import { SkyvernClient } from "@skyvern/client";
24+
25+
const client = new SkyvernClient({ xApiKey: "YOUR_X_API_KEY", apiKey: "YOUR_API_KEY" });
26+
await client.runTask({
27+
"x-user-agent": "x-user-agent",
28+
body: {
29+
prompt: "Find the top 3 posts on Hacker News."
30+
}
31+
});
32+
```
33+
34+
## Request And Response Types
35+
36+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
37+
following namespace:
38+
39+
```typescript
40+
import { Skyvern } from "@skyvern/client";
41+
42+
const request: Skyvern.RunTaskRequest = {
43+
...
44+
};
45+
```
46+
47+
## Exception Handling
48+
49+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
50+
will be thrown.
51+
52+
```typescript
53+
import { SkyvernError } from "@skyvern/client";
54+
55+
try {
56+
await client.runTask(...);
57+
} catch (err) {
58+
if (err instanceof SkyvernError) {
59+
console.log(err.statusCode);
60+
console.log(err.message);
61+
console.log(err.body);
62+
console.log(err.rawResponse);
63+
}
64+
}
65+
```
66+
67+
## Advanced
68+
69+
### Additional Headers
70+
71+
If you would like to send additional headers as part of the request, use the `headers` request option.
72+
73+
```typescript
74+
const response = await client.runTask(..., {
75+
headers: {
76+
'X-Custom-Header': 'custom value'
77+
}
78+
});
79+
```
80+
81+
### Additional Query String Parameters
82+
83+
If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
84+
85+
```typescript
86+
const response = await client.runTask(..., {
87+
queryParams: {
88+
'customQueryParamKey': 'custom query param value'
89+
}
90+
});
91+
```
92+
93+
### Retries
94+
95+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
96+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
97+
retry limit (default: 2).
98+
99+
A request is deemed retryable when any of the following HTTP status codes is returned:
100+
101+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
102+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
103+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
104+
105+
Use the `maxRetries` request option to configure this behavior.
106+
107+
```typescript
108+
const response = await client.runTask(..., {
109+
maxRetries: 0 // override maxRetries at the request level
110+
});
111+
```
112+
113+
### Timeouts
114+
115+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
116+
117+
```typescript
118+
const response = await client.runTask(..., {
119+
timeoutInSeconds: 30 // override timeout to 30s
120+
});
121+
```
122+
123+
### Aborting Requests
124+
125+
The SDK allows users to abort requests at any point by passing in an abort signal.
126+
127+
```typescript
128+
const controller = new AbortController();
129+
const response = await client.runTask(..., {
130+
abortSignal: controller.signal
131+
});
132+
controller.abort(); // aborts the request
133+
```
134+
135+
### Access Raw Response Data
136+
137+
The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
138+
The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
139+
140+
```typescript
141+
const { data, rawResponse } = await client.runTask(...).withRawResponse();
142+
143+
console.log(data);
144+
console.log(rawResponse.headers['X-My-Header']);
145+
```
146+
147+
### Runtime Compatibility
148+
149+
150+
The SDK works in the following runtimes:
151+
152+
153+
154+
- Node.js 18+
155+
- Vercel
156+
- Cloudflare Workers
157+
- Deno v1.25+
158+
- Bun 1.0+
159+
- React Native
160+
161+
### Customizing Fetch Client
162+
163+
The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
164+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
165+
166+
```typescript
167+
import { SkyvernClient } from "@skyvern/client";
168+
169+
const client = new SkyvernClient({
170+
...
171+
fetcher: // provide your implementation here
172+
});
173+
```
174+
175+
## Contributing
176+
177+
While we value open-source contributions to this SDK, this library is generated programmatically.
178+
Additions made directly to this library would have to be moved over to our generation code,
179+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
180+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
181+
an issue first to discuss with us!
182+
183+
On the other hand, contributions to the README are always very welcome!

skyvern-ts/client/biome.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
3+
"root": true,
4+
"vcs": {
5+
"enabled": false
6+
},
7+
"files": {
8+
"ignoreUnknown": true,
9+
"includes": [
10+
"./**",
11+
"!dist",
12+
"!lib",
13+
"!*.tsbuildinfo",
14+
"!_tmp_*",
15+
"!*.tmp",
16+
"!.tmp/",
17+
"!*.log",
18+
"!.DS_Store",
19+
"!Thumbs.db"
20+
]
21+
},
22+
"formatter": {
23+
"enabled": true,
24+
"indentStyle": "space",
25+
"indentWidth": 4,
26+
"lineWidth": 120
27+
},
28+
"javascript": {
29+
"formatter": {
30+
"quoteStyle": "double"
31+
}
32+
},
33+
"assist": {
34+
"enabled": true,
35+
"actions": {
36+
"source": {
37+
"organizeImports": "on"
38+
}
39+
}
40+
},
41+
"linter": {
42+
"rules": {
43+
"style": {
44+
"useNodejsImportProtocol": "off"
45+
},
46+
"suspicious": {
47+
"noAssignInExpressions": "warn",
48+
"noUselessEscapeInString": {
49+
"level": "warn",
50+
"fix": "none",
51+
"options": {}
52+
},
53+
"noThenProperty": "warn",
54+
"useIterableCallbackReturn": "warn",
55+
"noShadowRestrictedNames": "warn",
56+
"noTsIgnore": {
57+
"level": "warn",
58+
"fix": "none",
59+
"options": {}
60+
},
61+
"noConfusingVoidType": {
62+
"level": "warn",
63+
"fix": "none",
64+
"options": {}
65+
}
66+
}
67+
}
68+
}
69+
}

skyvern-ts/client/package.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"name": "@skyvern/client",
3+
"version": "0.2.18",
4+
"private": false,
5+
"repository": "github:Skyvern-AI/skyvern-typescript",
6+
"type": "commonjs",
7+
"main": "./dist/cjs/index.js",
8+
"module": "./dist/esm/index.mjs",
9+
"types": "./dist/cjs/index.d.ts",
10+
"exports": {
11+
".": {
12+
"types": "./dist/cjs/index.d.ts",
13+
"import": {
14+
"types": "./dist/esm/index.d.mts",
15+
"default": "./dist/esm/index.mjs"
16+
},
17+
"require": {
18+
"types": "./dist/cjs/index.d.ts",
19+
"default": "./dist/cjs/index.js"
20+
},
21+
"default": "./dist/cjs/index.js"
22+
},
23+
"./package.json": "./package.json"
24+
},
25+
"files": [
26+
"dist",
27+
"reference.md",
28+
"README.md",
29+
"LICENSE"
30+
],
31+
"scripts": {
32+
"format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
33+
"format:check": "biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
34+
"lint": "biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
35+
"lint:fix": "biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
36+
"check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
37+
"check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
38+
"build": "pnpm build:cjs && pnpm build:esm",
39+
"build:cjs": "tsc --project ./tsconfig.cjs.json",
40+
"build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
41+
"test": "vitest",
42+
"test:unit": "vitest --project unit",
43+
"test:wire": "vitest --project wire"
44+
},
45+
"devDependencies": {
46+
"webpack": "^5.97.1",
47+
"ts-loader": "^9.5.1",
48+
"vitest": "^3.2.4",
49+
"msw": "2.11.2",
50+
"@types/node": "^18.19.70",
51+
"typescript": "~5.7.2",
52+
"@biomejs/biome": "2.2.5"
53+
},
54+
"browser": {
55+
"fs": false,
56+
"os": false,
57+
"path": false,
58+
"stream": false
59+
},
60+
"packageManager": "[email protected]",
61+
"engines": {
62+
"node": ">=18.0.0"
63+
},
64+
"sideEffects": false
65+
}

0 commit comments

Comments
 (0)