@studio-foundation/api 0.3.0-beta.6 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +38 -17
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,19 +1,24 @@
1
1
  # @studio-foundation/api
2
2
 
3
- HTTP REST API for Studio. Same engine as the CLI, machine-to-machine interface. Like GitHub is to `git`.
3
+ **Studio** is a declarative YAML runtime for AI agents. It orchestrates multi-stage agent workflows with structured output validation and automatic retry. This package is the **HTTP REST API**: the machine-to-machine interface over the same engine the CLI uses. Like GitHub is to `git`.
4
4
 
5
- ## Role
5
+ It wraps the engine in a Fastify server and handles fire-and-forget pipeline launches, real-time SSE streaming, webhook dispatch (Linear, Slack, CI/CD), and integration lifecycle. Use it to drive Studio from anything that can make an HTTP call.
6
6
 
7
- api wraps the engine in a Fastify server. It handles fire-and-forget pipeline launches, real-time SSE streaming, webhook dispatch, and integration lifecycle (Linear, etc.). The CLI (`studio api start`) is the primary way to run it, but it can also be imported programmatically.
7
+ - Homepage: https://github.com/studio-foundation/studio
8
+ - Full docs: [README](https://github.com/studio-foundation/studio#readme) · [API reference](https://github.com/studio-foundation/studio/blob/main/API.md)
9
+ - Related: [`@studio-foundation/engine`](https://www.npmjs.com/package/@studio-foundation/engine) · [`@studio-foundation/cli`](https://www.npmjs.com/package/@studio-foundation/cli)
8
10
 
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @studio-foundation/api
15
+ # or
16
+ pnpm add @studio-foundation/api
9
17
  ```
10
- Linear webhook → POST /api/runs → launcher → engine → pipeline run → webhook dispatch
11
- Slack bot → POST /api/runs ↗
12
- CI/CD → POST /api/runs ↗
13
- Dashboard → GET /api/runs/:id/stream (SSE)
14
- ```
15
18
 
16
- ## Starting the server
19
+ The simplest way to start the server is via the CLI (`studio api start`), which is already wired up. Install this package directly if you want to embed the API in your own process.
20
+
21
+ ## Quick start
17
22
 
18
23
  ```bash
19
24
  # Via CLI (recommended)
@@ -21,13 +26,24 @@ studio api start
21
26
 
22
27
  # Standalone (PM2/systemd)
23
28
  STUDIO_CWD=/path/to/project node node_modules/.bin/studio-api
29
+ ```
24
30
 
25
- # Programmatic
31
+ Programmatic:
32
+
33
+ ```typescript
26
34
  import { createApi } from '@studio-foundation/api';
35
+
27
36
  const { server, cleanup } = await createApi({ cwd: '/path/to/project' });
28
37
  await server.listen({ port: 3700 });
29
38
  ```
30
39
 
40
+ ```
41
+ Linear webhook → POST /api/runs → launcher → engine → pipeline run → webhook dispatch
42
+ Slack bot → POST /api/runs ↗
43
+ CI/CD → POST /api/runs ↗
44
+ Dashboard → GET /api/runs/:id/stream (SSE)
45
+ ```
46
+
31
47
  ## Configuration
32
48
 
33
49
  The server reads `.studio/config.yaml` from the project directory (or the first `.studio/` found walking up from `STUDIO_CWD`):
@@ -135,15 +151,16 @@ es.addEventListener('pipeline_complete', (e) => { es.close(); });
135
151
 
136
152
  The API manages integration lifecycle (webhook routing, failure handling). Integrations are configured via `.studio/config.yaml` and declared via `.integration.yaml` files in `.studio/integrations/`.
137
153
 
138
- **Linear integration** drag an issue to "In Progress" → Studio receives the webhook → auto-launches the matching pipeline → posts results as a comment → moves the issue to "Done" on success.
154
+ **Linear integration**: drag an issue to "In Progress" → Studio receives the webhook → auto-launches the matching pipeline → posts results as a comment → moves the issue to "Done" on success.
139
155
 
140
156
  ## Sub-pipeline spawning
141
157
 
142
- The API uses `HttpApiSpawner` a self-referential `RunSpawner` that calls back into the same API to spawn child runs. This is how `studio_run` tool calls work when the engine is running behind the API.
158
+ The API uses `HttpApiSpawner`, a self-referential `RunSpawner` that calls back into the same API to spawn child runs. This is how `studio_run` tool calls work when the engine is running behind the API.
159
+
160
+ ## For contributors
143
161
 
144
- ## Bootstrap internals
162
+ Bootstrap internals — `bootstrap(cwd)` is the composition root:
145
163
 
146
- `bootstrap(cwd)` is the composition root:
147
164
  1. Finds `.studio/` by walking up from `cwd`
148
165
  2. Loads `config.yaml` (with `${ENV_VAR}` substitution)
149
166
  3. Creates `RunStore` based on `db.type` (`SQLiteRunStore` | `PgRunStore` | `InMemoryRunStore`)
@@ -153,9 +170,13 @@ The API uses `HttpApiSpawner` — a self-referential `RunSpawner` that calls bac
153
170
  7. Creates `WebhookStore`, `IntegrationStore`, `IntegrationRuntime`
154
171
  8. Returns `BootstrapResult` passed to `buildServer()`
155
172
 
156
- ## Rules
173
+ Internal rules that govern this package:
157
174
 
158
175
  - **api depends on engine + runner.** It is a composition root, same as cli.
159
- - **Routes must have complete Swagger schemas** tags, summary, params, response codes. Without this, routes don't appear in Swagger UI.
160
- - **The engine is the same.** The API doesn't bypass or wrap the engine it delegates to `InProcessLauncher`, which calls `PipelineEngine.run()` directly.
176
+ - **Routes must have complete Swagger schemas**: tags, summary, params, response codes. Without this, routes don't appear in Swagger UI.
177
+ - **The engine is the same.** The API doesn't bypass or wrap the engine, it delegates to `InProcessLauncher`, which calls `PipelineEngine.run()` directly.
161
178
  - `studio api start` calls `bootstrap()` then `buildServer()`. The two steps are separate so programmatic users can customize between them.
179
+
180
+ ## License
181
+
182
+ AGPL-3.0-only
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@studio-foundation/api",
3
- "version": "0.3.0-beta.6",
4
- "description": "HTTP API for Studio v7",
3
+ "version": "0.5.2",
4
+ "description": "HTTP REST API server for Studio agent pipelines",
5
5
  "type": "module",
6
6
  "main": "./dist/api.js",
7
7
  "types": "./dist/api.d.ts",
@@ -39,9 +39,9 @@
39
39
  "fastify": "^5.3.2",
40
40
  "js-yaml": "^4.1.1",
41
41
  "pg": "^8.19.0",
42
- "@studio-foundation/runner": "0.3.0-beta.6",
43
- "@studio-foundation/engine": "0.3.0-beta.6",
44
- "@studio-foundation/contracts": "0.3.0-beta.6"
42
+ "@studio-foundation/contracts": "0.5.2",
43
+ "@studio-foundation/engine": "0.5.2",
44
+ "@studio-foundation/runner": "0.5.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/better-sqlite3": "^7.6.8",