terse-sdk 0.1.2 → 0.1.3
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 +58 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# terse-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for building jobs on the [Terse](https://terse.ai) platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install terse-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Terse, TerseAgent } from "terse-sdk";
|
|
15
|
+
import { GitHub, Slack, Repos, SlackChannel } from "./terse.generated";
|
|
16
|
+
|
|
17
|
+
const client = new Terse();
|
|
18
|
+
|
|
19
|
+
client.createJob({
|
|
20
|
+
name: "PR Summary Bot",
|
|
21
|
+
triggers: [GitHub.onPROpened({ repo: Repos.MyOrg.MyRepo })],
|
|
22
|
+
skills: [GitHub.skill({ repos: [Repos.MyOrg.MyRepo] }), Slack.skill({ channel: SlackChannel.General })],
|
|
23
|
+
onTrigger: async (event, Agent) => {
|
|
24
|
+
await Agent.runAndWait(`Summarize this PR: ${event.formatForAgentRunner()}`);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Core Concepts
|
|
30
|
+
|
|
31
|
+
- **`Terse`** — Entry point. Use `createJob()` to register jobs.
|
|
32
|
+
- **`TerseAgent`** — Passed into your `onTrigger` handler. Call `agent.run()` for streaming results or `agent.runAndWait()` to run to completion.
|
|
33
|
+
- **Triggers** — Config instances (e.g. `GitHub.onPROpened()`) that define when a job fires.
|
|
34
|
+
- **Skills** — Integration configs (e.g. `Slack.skill()`) that give the agent access to tools.
|
|
35
|
+
- **Events** — Typed input events (`GithubPRInputEvent`, `WorkOSUserInputEvent`, etc.) with type guards like `isGithubPREvent()`.
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `TerseAgent`
|
|
40
|
+
|
|
41
|
+
| Method | Description |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `run(prompt, event?)` | Returns an `AsyncGenerator<TerseAgentResult>` streaming agent output |
|
|
44
|
+
| `runAndWait(prompt, event?)` | Runs the agent to completion, discarding streamed output |
|
|
45
|
+
| `executeTool(toolName, params?)` | Directly execute a single tool by name |
|
|
46
|
+
|
|
47
|
+
### Event Types
|
|
48
|
+
|
|
49
|
+
The SDK provides typed event classes and type guards for supported integrations:
|
|
50
|
+
|
|
51
|
+
- **GitHub**: `GithubInputEvent`, `GithubPRInputEvent`, `GithubPushInputEvent`
|
|
52
|
+
- **WorkOS**: `WorkOSUserInputEvent`, `WorkOSMembershipInputEvent`, `WorkOSInvitationInputEvent`
|
|
53
|
+
|
|
54
|
+
## Environment Variables
|
|
55
|
+
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `TERSE_API_KEY` | Required. API key for authenticating with the Terse platform. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terse-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prebuild": "node ../../scripts/copy-shared.js",
|
|
12
12
|
"build": "tsc",
|
|
13
|
-
"install-global": "
|
|
13
|
+
"install-global": "npm run build && npm link"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "^5.0.0"
|