@softr/sdk 0.0.90-alpha.1 → 0.0.90-alpha.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/dist/mcp.d.ts +2 -2
- package/dist/package.js +1 -1
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/agent-chat/SKILL.md +22 -60
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/charts-and-metrics/SKILL.md +1 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/file-uploads/SKILL.md +1 -1
- package/skills/softr-sdk/formatting/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +1 -1
- package/skills/softr-sdk/mcp/SKILL.md +1 -1
- package/skills/softr-sdk/pwa/SKILL.md +1 -1
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +1 -1
- package/skills/softr-sdk/region-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatasourceAction } from "./action.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _tanstack_react_start0 from "@tanstack/react-start";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
|
|
@@ -31,6 +31,6 @@ type SoftrMcpOptions = {
|
|
|
31
31
|
* ],
|
|
32
32
|
* }))
|
|
33
33
|
*/
|
|
34
|
-
declare function softrMcpMiddleware(options?: SoftrMcpOptions):
|
|
34
|
+
declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start0.RequestMiddlewareAfterServer<{}, undefined, undefined>;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { softrMcpMiddleware };
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-chat
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
@softr/sdk
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
chat panel, approving the agent's actions, or connecting the visitor's own
|
|
9
|
-
account (Gmail, Slack…) that a tool needs. Build the chat from the app's own
|
|
10
|
-
components. The agent acts on the app's data through the app's MCP, so
|
|
11
|
-
softrMcpMiddleware must list the actions it may use.
|
|
4
|
+
Chat with one of the app's Softr agents: listAgents() and useAgentChat(agentId,
|
|
5
|
+
{ record }) from @softr/sdk give the chat state with no UI — messages, the
|
|
6
|
+
streaming reply, past chats, approve, reject, connect. Load it for an agent
|
|
7
|
+
chat, approving its actions, or connecting the visitor's account a tool needs.
|
|
12
8
|
metadata:
|
|
13
9
|
type: sub-skill
|
|
14
10
|
library: softr-sdk
|
|
15
|
-
library_version: 0.0.90-alpha.
|
|
11
|
+
library_version: 0.0.90-alpha.3
|
|
16
12
|
---
|
|
17
13
|
|
|
18
14
|
**Boundary.** `listAgents` and `useAgentChat` live on `@softr/sdk`. `listAgents` runs in a route loader, `useAgentChat` in a component. Neither needs a route, server function or registration of its own. It chats as the signed-in visitor, or anonymously when no one is signed in.
|
|
19
15
|
|
|
20
16
|
# Agent chat
|
|
21
17
|
|
|
22
|
-
A Softr agent is set up in Studio's Agents tab and attached to the app there.
|
|
18
|
+
A Softr agent is set up in Studio's Agents tab and attached to the app there. There is no chat widget: the hook gives the state, and the app draws it with its own components.
|
|
23
19
|
|
|
24
20
|
## Setup
|
|
25
21
|
|
|
@@ -27,7 +23,7 @@ A Softr agent is set up in Studio's Agents tab and attached to the app there. Th
|
|
|
27
23
|
import { listAgents, useAgentChat } from '@softr/sdk'
|
|
28
24
|
```
|
|
29
25
|
|
|
30
|
-
`listAgents()` resolves to the agents this visitor may chat with, `{ id, title, avatar, thumbnail }[]`. Call it in the route's `loader`. An agent hidden from this visitor isn't in the list, so show no chat when it's empty. When there are several, let the visitor pick one, or pick the one the builder named by its `title`. Take the id from the list,
|
|
26
|
+
`listAgents()` resolves to the agents this visitor may chat with, `{ id, title, avatar, thumbnail }[]`. Call it in the route's `loader`. An agent hidden from this visitor isn't in the list, so show no chat when it's empty. When there are several, let the visitor pick one, or pick the one the builder named by its `title`. Take the id from the list. A hand-written id fails on the first message, and shows an agent the visitor may not see.
|
|
31
27
|
|
|
32
28
|
## Core pattern
|
|
33
29
|
|
|
@@ -58,7 +54,7 @@ function AgentPanel({ agentId, ticket }: { agentId: string; ticket: Ticket | nul
|
|
|
58
54
|
|
|
59
55
|
## What the hook returns
|
|
60
56
|
|
|
61
|
-
- `messages`: the whole chat, oldest first. While the agent answers, its reply is the last message and grows as it streams.
|
|
57
|
+
- `messages`: the whole chat, oldest first. While the agent answers, its reply is the last message and grows as it streams.
|
|
62
58
|
- `status`: `thinking` until the first part of the reply arrives, `replying` until it ends, then `idle`. Show a typing hint while it's `thinking`.
|
|
63
59
|
- `loading`: `true` while a past chat loads. Show a spinner, not the empty-chat greeting.
|
|
64
60
|
- `error`: why the last request failed, or `null`.
|
|
@@ -69,54 +65,19 @@ function AgentPanel({ agentId, ticket }: { agentId: string; ticket: Ticket | nul
|
|
|
69
65
|
|
|
70
66
|
## Rendering a message
|
|
71
67
|
|
|
72
|
-
Each message has `role` (`user` or `assistant`) and `blocks
|
|
68
|
+
Each message has `role` (`user` or `assistant`) and `blocks`. Render every block type, in the order given. Show only `text` and a tool waiting for approval never appears, so the agent waits forever. A tool waiting for Approve or Connect comes last in its message, below the text asking for it.
|
|
73
69
|
|
|
74
70
|
| Block | Show it as |
|
|
75
71
|
| --- | --- |
|
|
76
|
-
| `text` | Markdown
|
|
77
|
-
| `tool` | One line: the tool `name` and its `status`. Collapse finished ones. Expanded, show `thought`, `input
|
|
72
|
+
| `text` | Markdown, tables included |
|
|
73
|
+
| `tool` | One line: the tool `name` and its `status`. Collapse finished ones. Expanded, show `thought`, `input` as `Label: value` lines (never raw JSON), `error` and `durationMs`, leaving out empty ones. |
|
|
78
74
|
| `todo` | A checklist of the agent's plan. It updates in place. |
|
|
79
|
-
| `question` | The questions with their options. One question with a single choice sends its label with `send` on click. Several questions, or `multiSelect`, collect the picks and show a Send button, enabled once each question has one. It sends one line per question, picked labels joined by ", ". |
|
|
75
|
+
| `question` | The questions with their options. One question with a single choice sends its label with `send` on click. Several questions, or `multiSelect`, collect the picks and show a Send button, enabled once each question has one. It sends one line per question, picked labels joined by ", ". An answered question stays locked. |
|
|
80
76
|
| `error` | An error line inside the reply |
|
|
81
77
|
|
|
82
|
-
A `tool` with status `awaiting-approval` blocks the agent until the visitor answers. Give it a split Approve button and a Reject button
|
|
83
|
-
|
|
84
|
-
A `tool` with status `awaiting-connection` needs the visitor's own `integration` account, such as their Gmail. Say "You need to connect to {integration} for this request. You'll only need to connect once.", with the name in readable case, and show a Connect button that calls `connect`. While it's `connecting`, show "Connecting…" and disable the button. The agent continues on its own once they're signed in.
|
|
85
|
-
|
|
86
|
-
## The chat panel
|
|
87
|
-
|
|
88
|
-
Classic Softr apps ship a chat panel. Visitors expect the same from yours:
|
|
89
|
-
|
|
90
|
-
- A round `primary` button in a corner opens it: about 56px, a soft shadow, the agent's avatar or a chat icon. It hides while the panel is open.
|
|
91
|
-
- The panel opens on the right on desktop, about 420px wide with a left border and a large shadow, and full screen on mobile.
|
|
92
|
-
- The header shows the agent's avatar and name, a picker when there are several agents, new chat, past chats and close.
|
|
93
|
-
- An empty chat greets the visitor with the agent's avatar.
|
|
94
|
-
- The list scrolls to the newest message as the reply streams, until the visitor scrolls up. Then a button takes them back down.
|
|
95
|
-
- Text renders as Markdown, tables included.
|
|
96
|
-
- The input says "Ask {agent title}…". Enter sends. Shift+Enter adds a line.
|
|
97
|
-
- A line under the input: "AI can make mistakes. Please double-check responses."
|
|
98
|
-
- An answered question stays locked.
|
|
99
|
-
- A tool's `input` is JSON. Show it readable: one `Label: value` line per field, with line breaks kept, never the raw JSON. Leave out `thought`, `input`, `error` or the duration when it's empty.
|
|
100
|
-
- A tool that needs the visitor's account shows a Connect button.
|
|
101
|
-
|
|
102
|
-
## How it looks
|
|
103
|
-
|
|
104
|
-
The chat is the visitor's first impression of the agent. These are defaults for the first build. When the builder asks for a different look, follow them instead.
|
|
105
|
-
|
|
106
|
-
- **The app's own look.** Build it from the app's own primitives and match its pages, so it never reads as a third-party widget.
|
|
107
|
-
- **One loud thing at a time.** The answer is the content. Tool lines stay quiet. Only a block that waits for the visitor (approve, connect, question) stands out.
|
|
108
|
-
- **Layout.** Three zones: a fixed header, the scrolling messages, a fixed composer. Use `text-sm` throughout.
|
|
109
|
-
- **Header.** A small round avatar, the agent's name, and a muted line under it (the agent picker, when there are several). Actions are ghost icon buttons with tooltips.
|
|
110
|
-
- **Visitor messages.** Right-aligned bubbles in `primary`, generously rounded, at most 85% wide.
|
|
111
|
-
- **Agent replies.** No bubble. Full width on the background, with a small avatar at the start of each reply, so long answers and tables read like a page.
|
|
112
|
-
- **Markdown.** Comfortable paragraph and list spacing. Inline code on `muted`. Tables bordered, in a horizontal scroll wrapper, never wider than the panel. Links in `primary`.
|
|
113
|
-
- **Tools.** One `text-xs` muted line with a status icon: a spinner while running, a check when done, an alert on error. Click to expand.
|
|
114
|
-
- **Blocks that wait for the visitor.** A `card` with a border, a rounded corner and padding: a one-line title, a short explanation, buttons on the right. The main action is `primary`, the other `outline`.
|
|
115
|
-
- **Thinking.** Where the reply will appear, a muted "Thinking…" with a gentle pulse or shimmer.
|
|
116
|
-
- **Empty chat.** Centred: a large avatar, "Hi, I'm {agent title}", one muted line inviting a question. Add two to four suggestion chips only when the builder said what the agent does; they send on click.
|
|
117
|
-
- **Composer.** One rounded, bordered box that holds the textarea and an icon send button in its corner, with the focus ring on the box. The textarea grows to about six lines, then scrolls. The disclaimer sits under it in `text-xs` muted, centred.
|
|
118
|
-
- **Spacing.** Clear space between turns, tight space inside a turn.
|
|
119
|
-
- **Motion.** The panel slides in and new messages fade in, both short, and they respect reduced motion. Nothing bounces.
|
|
78
|
+
A `tool` with status `awaiting-approval` blocks the agent until the visitor answers. Give it a split Approve button and a Reject button. The button says "Approve once" (`approve(id)`), and its menu offers "Approve for this session" (`approve(id, 'SESSION')`) and "Approve for this agent" (`approve(id, 'USER')`). With only one Approve, the visitor approves the same action again on every call. The agent continues on its own after an approval.
|
|
79
|
+
|
|
80
|
+
A `tool` with status `awaiting-connection` needs the visitor's own `integration` account, such as their Gmail. Say "You need to connect to {integration} for this request. You'll only need to connect once.", with the name in readable case, and show a Connect button that calls `connect`. While it's `connecting`, show "Connecting…" and disable the button. The agent continues on its own once they're signed in. Every integration works the same way, so build one button, not one per integration.
|
|
120
81
|
|
|
121
82
|
## Context
|
|
122
83
|
|
|
@@ -126,17 +87,18 @@ The page title and URL go along on their own. Nothing else about the page does,
|
|
|
126
87
|
|
|
127
88
|
## Letting the agent act on the app
|
|
128
89
|
|
|
129
|
-
The agent reads and changes data through the app's own MCP, as the visitor who is chatting
|
|
90
|
+
The agent reads and changes data through the app's own MCP, as the visitor who is chatting, using the actions `softrMcpMiddleware` lists. With no MCP wired, the agent can only talk. Load [mcp/SKILL.md](../mcp/SKILL.md) to wire it and choose the actions.
|
|
130
91
|
|
|
131
|
-
|
|
92
|
+
**The agent calls a listed action directly, with any input.** It skips pages and server functions, so the action's `permissions` are its only guard: a read returns every row those groups may see, an update or delete takes any id.
|
|
132
93
|
|
|
133
|
-
|
|
94
|
+
- Narrow `permissions` to who may really run it. When roles differ, split the action: each writes only that role's fields, with `customGroups` for that role. One update open to every signed-in visitor that writes the status lets an employee have the agent approve their own vacation request.
|
|
95
|
+
- Don't list an action that is only safe for a visitor's own records. Nothing scopes it to them.
|
|
134
96
|
|
|
135
|
-
|
|
97
|
+
## Failure modes
|
|
136
98
|
|
|
137
|
-
**
|
|
99
|
+
**Building a chat without the hook.** Calling the agents service from the browser fails: only the app's server can sign the request in as the visitor. Use `useAgentChat`.
|
|
138
100
|
|
|
139
|
-
**
|
|
101
|
+
**The hook inside a component that unmounts when the panel closes.** Closing it stops a reply that is still coming. Call `useAgentChat` in the component that owns the panel's open state and pass `chat` down. Keep the selected agent there too, or closing the panel resets it.
|
|
140
102
|
|
|
141
103
|
## References
|
|
142
104
|
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 0.0.90-alpha.
|
|
10
|
+
library_version: 0.0.90-alpha.3
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk` and run in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 0.0.90-alpha.
|
|
10
|
+
library_version: 0.0.90-alpha.3
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `integration` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineIntegration` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `softrMcpMiddleware` lives on `@softr/sdk` and is registered once, in `src/start.ts`. The actions you hand it are the same `defineQuery` / `defineMutation` values the app's own pages use — declared wherever they already live, not duplicated for MCP.
|
|
@@ -8,7 +8,7 @@ description: >-
|
|
|
8
8
|
metadata:
|
|
9
9
|
type: sub-skill
|
|
10
10
|
library: softr-sdk
|
|
11
|
-
library_version: 0.0.90-alpha.
|
|
11
|
+
library_version: 0.0.90-alpha.3
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `definePage`, `pageHead`, the access functions and the error predicates come from `@softr/sdk` and work anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 0.0.90-alpha.
|
|
12
|
+
library_version: 0.0.90-alpha.3
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `workflow` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineWorkflow` and every type come from `@softr/sdk` and can be imported anywhere.
|