@softr/sdk 0.0.90-alpha.2 → 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/default-error-overlay.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/pwa.d.ts +2 -2
- package/package.json +1 -1
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/agent-chat/SKILL.md +18 -57
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react6 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/default-error-overlay.d.ts
|
|
4
4
|
type Props = {
|
|
@@ -8,6 +8,6 @@ type Props = {
|
|
|
8
8
|
declare function DefaultErrorOverlay({
|
|
9
9
|
error,
|
|
10
10
|
reset
|
|
11
|
-
}: Props):
|
|
11
|
+
}: Props): react6.JSX.Element;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { DefaultErrorOverlay };
|
package/dist/package.js
CHANGED
package/dist/pwa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
import "@tanstack/react-start";
|
|
3
3
|
|
|
4
4
|
//#region src/pwa.d.ts
|
|
@@ -23,7 +23,7 @@ import "@tanstack/react-start";
|
|
|
23
23
|
* )
|
|
24
24
|
* }
|
|
25
25
|
*/
|
|
26
|
-
declare function SoftrPwaHead():
|
|
26
|
+
declare function SoftrPwaHead(): react4.FunctionComponentElement<react4.FragmentProps>;
|
|
27
27
|
type PwaPlatform = "ios" | "android" | "desktop";
|
|
28
28
|
type PwaInstall = {
|
|
29
29
|
available: false;
|
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,46 +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
|
|
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.
|
|
83
79
|
|
|
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
|
-
Visitors expect the panel classic Softr apps ship:
|
|
89
|
-
|
|
90
|
-
- A round `primary` button in a corner opens it, with the agent's avatar or a chat icon. It hides while the panel is open.
|
|
91
|
-
- A right-side panel, about 420px, full screen on mobile.
|
|
92
|
-
- Header: avatar, name, agent picker when there are several, new chat, past chats, close.
|
|
93
|
-
- The list follows the streaming reply until the visitor scrolls up, then offers a jump back down.
|
|
94
|
-
- Text renders as Markdown, tables included.
|
|
95
|
-
- The input says "Ask {agent title}…". Enter sends, Shift+Enter adds a line. Under it: "AI can make mistakes. Please double-check responses."
|
|
96
|
-
- An answered question stays locked.
|
|
97
|
-
- A tool's `input` shows as `Label: value` lines, never raw JSON. Empty `thought`, `input`, `error` or duration are left out.
|
|
98
|
-
|
|
99
|
-
## How it looks
|
|
100
|
-
|
|
101
|
-
Defaults for the first build. The builder's prompt overrides them.
|
|
102
|
-
|
|
103
|
-
- Reuse the app's own components and styles: its Markdown renderer, cards, buttons, avatars. Add no copies and no new colours.
|
|
104
|
-
- One loud thing at a time. Tool lines stay quiet; only a block waiting for the visitor stands out.
|
|
105
|
-
- Visitor messages are right-aligned `primary` bubbles. Agent replies have no bubble and run full width, so tables read like a page.
|
|
106
|
-
- A tool is one muted `text-xs` line with a status icon, expandable.
|
|
107
|
-
- Approve, connect and questions sit in a `card`: a title, a short line, the main action `primary`.
|
|
108
|
-
- While `thinking`, a muted pulsing "Thinking…" where the reply will appear.
|
|
109
|
-
- An empty chat shows a large avatar and "Hi, I'm {agent title}". Add suggestion chips only when the builder said what the agent does.
|
|
110
|
-
- The composer is one rounded box holding the textarea and send button. It grows to about six lines.
|
|
111
|
-
- Short slide and fade motion that respects reduced motion.
|
|
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.
|
|
112
81
|
|
|
113
82
|
## Context
|
|
114
83
|
|
|
@@ -118,26 +87,18 @@ The page title and URL go along on their own. Nothing else about the page does,
|
|
|
118
87
|
|
|
119
88
|
## Letting the agent act on the app
|
|
120
89
|
|
|
121
|
-
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.
|
|
122
91
|
|
|
123
|
-
**The agent calls a listed action directly, with any input.**
|
|
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.
|
|
124
93
|
|
|
125
|
-
-
|
|
126
|
-
- 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.
|
|
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.
|
|
127
95
|
- Don't list an action that is only safe for a visitor's own records. Nothing scopes it to them.
|
|
128
|
-
- Tell the builder which actions the agent can use and who may run each one.
|
|
129
96
|
|
|
130
97
|
## Failure modes
|
|
131
98
|
|
|
132
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`.
|
|
133
100
|
|
|
134
|
-
**
|
|
135
|
-
|
|
136
|
-
**The hook inside a panel that unmounts when it closes.** Closing it stops a reply that is still coming. Call `useAgentChat` in the component that owns the open state, such as `AppLayout` in `src/routes/_app.tsx`, and pass `chat` into the panel. Keep the selected agent there too, or closing the panel resets it.
|
|
137
|
-
|
|
138
|
-
**One action for every role.** An update any signed-in visitor may run, writing the status, lets an employee have the agent approve their own vacation request. Give approve its own action, limited to managers.
|
|
139
|
-
|
|
140
|
-
**An agent id written by hand.** The chat fails on the first message, and an agent hidden from the visitor still shows. Take the id from `listAgents`.
|
|
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.
|
|
141
102
|
|
|
142
103
|
## References
|
|
143
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.
|