@swirls/sdk 0.0.10 → 0.0.12

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 CHANGED
@@ -14,7 +14,7 @@ The [`@swirls/sdk/client`](src/client/README.md) subpackage provides a type-safe
14
14
  import { Swirls } from '@swirls/sdk/client'
15
15
 
16
16
  const swirls = new Swirls({ apiKey: process.env.SWIRLS_API_KEY! })
17
- const graphs = await swirls.graphs.listGraphs({ projectId })
17
+ const graphs = await swirls.client.graphs.listGraphs({ input: { projectId } })
18
18
  // With React: useQuery(swirls.query.graphs.listGraphs.queryOptions({ input: { projectId } }))
19
19
  ```
20
20
 
@@ -34,6 +34,36 @@ The [`@swirls/sdk/form`](src/form/README.md) subpackage provides a form library
34
34
  import { useSwirlsFormAdapter } from '@swirls/sdk/form'
35
35
  ```
36
36
 
37
+ ### Graph Builder
38
+
39
+ The [`@swirls/sdk/graph`](src/graph/README.md) subpackage lets you build and manipulate workflow graphs in code. Use a fluent API to add nodes and edges by name, then validate (DAG, single root), persist via the API with `save()`, or serialize with `toJSON()` for storage or version control. Dynamic values (e.g. LLM prompts, code transforms) use TypeScript function bodies with a `context` object; when you set `inputSchema` and `outputSchema` on nodes, `context.inputs` is typed for intellisense.
40
+
41
+ ```typescript
42
+ import { Swirls } from '@swirls/sdk/client'
43
+ import { GraphBuilder } from '@swirls/sdk/graph'
44
+
45
+ const swirls = new Swirls({ apiKey: process.env.SWIRLS_API_KEY! })
46
+ const graph = new GraphBuilder({ client: swirls.client })
47
+ .setName('my_workflow')
48
+ .setLabel('My Workflow')
49
+ .addNode('fetch', {
50
+ type: 'http',
51
+ label: 'Fetch',
52
+ config: { type: 'http', url: 'https://api.example.com/data', method: 'GET' },
53
+ })
54
+ .addNode('summarize', {
55
+ type: 'llm',
56
+ label: 'Summarize',
57
+ config: {
58
+ type: 'llm',
59
+ model: 'gpt-4o',
60
+ prompt: 'return `Summarize the following: ${context.inputs.fetch.output}`',
61
+ },
62
+ })
63
+ .addEdge({ source: 'fetch', target: 'summarize' })
64
+ await graph.save({ projectId: '...' })
65
+ ```
66
+
37
67
  ## Installation
38
68
 
39
69
  ```sh
@@ -52,3 +82,4 @@ bun add @tanstack/react-query
52
82
  - [Client Documentation](src/client/README.md): API client and TanStack Query utils
53
83
  - [Config Documentation](src/config/README.md): Configuration reference
54
84
  - [Form Documentation](src/form/README.md): Complete guide to forms
85
+ - [Graph Documentation](src/graph/README.md): Build and manipulate workflow graphs