@jskit-ai/agent-docs 0.1.1
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/DISTR_AGENT.md +25 -0
- package/guide/agent/app-extras/assistant.md +636 -0
- package/guide/agent/app-extras/realtime.md +223 -0
- package/guide/agent/app-setup/a-more-interesting-shell.md +643 -0
- package/guide/agent/app-setup/authentication.md +948 -0
- package/guide/agent/app-setup/console.md +316 -0
- package/guide/agent/app-setup/database-layer.md +775 -0
- package/guide/agent/app-setup/initial-scaffolding.md +714 -0
- package/guide/agent/app-setup/multi-homing.md +655 -0
- package/guide/agent/app-setup/users.md +355 -0
- package/guide/agent/app-setup/working-with-the-jskit-cli.md +983 -0
- package/guide/agent/generators/advanced-cruds.md +923 -0
- package/guide/agent/generators/crud-generators.md +556 -0
- package/guide/agent/generators/intro.md +63 -0
- package/guide/agent/generators/ui-generators.md +648 -0
- package/guide/agent/index.md +39 -0
- package/guide/human/app-extras/assistant.md +695 -0
- package/guide/human/app-extras/realtime.md +270 -0
- package/guide/human/app-setup/a-more-interesting-shell.md +734 -0
- package/guide/human/app-setup/authentication.md +963 -0
- package/guide/human/app-setup/console.md +352 -0
- package/guide/human/app-setup/database-layer.md +822 -0
- package/guide/human/app-setup/initial-scaffolding.md +738 -0
- package/guide/human/app-setup/multi-homing.md +795 -0
- package/guide/human/app-setup/users.md +404 -0
- package/guide/human/app-setup/working-with-the-jskit-cli.md +997 -0
- package/guide/human/generators/advanced-cruds.md +923 -0
- package/guide/human/generators/crud-generators.md +556 -0
- package/guide/human/generators/intro.md +109 -0
- package/guide/human/generators/ui-generators.md +665 -0
- package/guide/human/index.md +39 -0
- package/package.json +28 -0
- package/reference/autogen/KERNEL_MAP.md +536 -0
- package/reference/autogen/README.md +44 -0
- package/reference/autogen/packages/agent-docs.md +13 -0
- package/reference/autogen/packages/assistant-core.md +310 -0
- package/reference/autogen/packages/assistant-runtime.md +219 -0
- package/reference/autogen/packages/assistant.md +73 -0
- package/reference/autogen/packages/auth-core.md +352 -0
- package/reference/autogen/packages/auth-provider-supabase-core.md +223 -0
- package/reference/autogen/packages/auth-web.md +267 -0
- package/reference/autogen/packages/console-core.md +116 -0
- package/reference/autogen/packages/console-web.md +37 -0
- package/reference/autogen/packages/crud-core.md +283 -0
- package/reference/autogen/packages/crud-server-generator.md +220 -0
- package/reference/autogen/packages/crud-ui-generator.md +154 -0
- package/reference/autogen/packages/database-runtime-mysql.md +61 -0
- package/reference/autogen/packages/database-runtime-postgres.md +39 -0
- package/reference/autogen/packages/database-runtime.md +216 -0
- package/reference/autogen/packages/http-runtime.md +213 -0
- package/reference/autogen/packages/kernel.md +1350 -0
- package/reference/autogen/packages/realtime.md +95 -0
- package/reference/autogen/packages/shell-web.md +349 -0
- package/reference/autogen/packages/storage-runtime.md +39 -0
- package/reference/autogen/packages/ui-generator.md +101 -0
- package/reference/autogen/packages/uploads-image-web.md +76 -0
- package/reference/autogen/packages/uploads-runtime.md +85 -0
- package/reference/autogen/packages/users-core.md +307 -0
- package/reference/autogen/packages/users-web.md +473 -0
- package/reference/autogen/packages/workspaces-core.md +415 -0
- package/reference/autogen/packages/workspaces-web.md +372 -0
- package/reference/autogen/tooling/config-eslint.md +52 -0
- package/reference/autogen/tooling/create-app.md +194 -0
- package/reference/autogen/tooling/jskit-catalog.md +27 -0
- package/reference/autogen/tooling/jskit-cli.md +624 -0
- package/reference/autogen/tooling/test-support.md +27 -0
- package/reference/autogen/tooling/testUtils.md +31 -0
- package/templates/APP_BLUEPRINT.md +57 -0
- package/workflow/app-state.md +33 -0
- package/workflow/bootstrap.md +24 -0
- package/workflow/feature-delivery.md +21 -0
- package/workflow/review.md +22 -0
- package/workflow/scoping.md +26 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
<!-- Generated by `npm run agent-docs:build` from `docs/guide/app-extras/assistant.md`. Do not edit manually. -->
|
|
2
|
+
|
|
3
|
+
# Assistant
|
|
4
|
+
|
|
5
|
+
At the end of the previous chapter, the app could already host live transports, but it still had no assistant surface of its own.
|
|
6
|
+
|
|
7
|
+
Assistant setup in JSKIT happens in two layers:
|
|
8
|
+
|
|
9
|
+
- `assistant-runtime`
|
|
10
|
+
- the real runtime package
|
|
11
|
+
- owns the shared tables, routes, client runtime, and config registries
|
|
12
|
+
- `assistant`
|
|
13
|
+
- a generator package used through `npx jskit generate assistant ...`
|
|
14
|
+
- scaffolds pages and writes per-surface assistant configuration
|
|
15
|
+
|
|
16
|
+
That split is the main thing to understand before you start. Installing the runtime does **not** automatically create assistant pages. The generator commands decide which surfaces get assistants and where each assistant is configured.
|
|
17
|
+
|
|
18
|
+
In this chapter, we set up three assistants with three different roles:
|
|
19
|
+
|
|
20
|
+
- a `console` assistant configured in `console`
|
|
21
|
+
- an `admin` assistant configured from `console`
|
|
22
|
+
- an `app` assistant configured from `admin`, with one configuration per workspace
|
|
23
|
+
|
|
24
|
+
## Recap from previous chapters
|
|
25
|
+
|
|
26
|
+
To get back to the same starting point as the end of the previous chapter, run:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
SUPABASE_URL=...
|
|
30
|
+
SUPABASE_KEY=...
|
|
31
|
+
DB_HOST=127.0.0.1
|
|
32
|
+
DB_PORT=3306
|
|
33
|
+
DB_NAME=exampleapp
|
|
34
|
+
DB_USER=exampleapp
|
|
35
|
+
DB_PASSWORD=secret
|
|
36
|
+
|
|
37
|
+
npx @jskit-ai/create-app exampleapp --tenancy-mode personal
|
|
38
|
+
cd exampleapp
|
|
39
|
+
npm install
|
|
40
|
+
|
|
41
|
+
npx jskit add package shell-web
|
|
42
|
+
npx jskit add package auth-provider-supabase-core \
|
|
43
|
+
--auth-supabase-url "$SUPABASE_URL" \
|
|
44
|
+
--auth-supabase-publishable-key "$SUPABASE_KEY" \
|
|
45
|
+
--app-public-url "http://localhost:5173"
|
|
46
|
+
npx jskit add bundle auth-base
|
|
47
|
+
npx jskit add package database-runtime-mysql \
|
|
48
|
+
--db-host "$DB_HOST" \
|
|
49
|
+
--db-port "$DB_PORT" \
|
|
50
|
+
--db-name "$DB_NAME" \
|
|
51
|
+
--db-user "$DB_USER" \
|
|
52
|
+
--db-password "$DB_PASSWORD"
|
|
53
|
+
npx jskit add package users-web
|
|
54
|
+
npx jskit add package console-web
|
|
55
|
+
npx jskit add package workspaces-core
|
|
56
|
+
npx jskit add package workspaces-web
|
|
57
|
+
npx jskit add package realtime
|
|
58
|
+
npm install
|
|
59
|
+
npm run db:migrate
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you are already continuing from the previous chapter, you are already in the right place and can skip that setup.
|
|
63
|
+
|
|
64
|
+
<DocsTerminalTip label="Important" title="`assistant-runtime` And `assistant` Are Different">
|
|
65
|
+
`assistant-runtime` is the package you install into the app with `jskit add package`.
|
|
66
|
+
|
|
67
|
+
`assistant` is the generator you use afterwards with:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx jskit generate assistant ...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
That means the flow is:
|
|
74
|
+
|
|
75
|
+
1. install `assistant-runtime`
|
|
76
|
+
2. run `npm install`
|
|
77
|
+
3. run `npm run db:migrate`
|
|
78
|
+
4. use the `assistant` generator to define assistant surfaces and scaffold pages
|
|
79
|
+
|
|
80
|
+
The runtime package brings the engine. The generator decides how your app exposes that engine.
|
|
81
|
+
</DocsTerminalTip>
|
|
82
|
+
|
|
83
|
+
## Installing `assistant-runtime`
|
|
84
|
+
|
|
85
|
+
From inside `exampleapp`, run:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npx jskit add package assistant-runtime
|
|
89
|
+
npm install
|
|
90
|
+
npm run db:migrate
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This chapter needs the migration step because `assistant-runtime` installs real schema files for:
|
|
94
|
+
|
|
95
|
+
- assistant configuration
|
|
96
|
+
- assistant transcripts
|
|
97
|
+
|
|
98
|
+
After this install, the app has the shared runtime pieces, but it still does **not** have any assistant pages. That is the next step.
|
|
99
|
+
|
|
100
|
+
## Three ideas you need before running the generator
|
|
101
|
+
|
|
102
|
+
The assistant generator revolves around three separate ideas:
|
|
103
|
+
|
|
104
|
+
- **runtime surface**
|
|
105
|
+
- where the assistant chat UI actually lives
|
|
106
|
+
- **settings surface**
|
|
107
|
+
- where the assistant settings screen lives
|
|
108
|
+
- **config scope**
|
|
109
|
+
- whether the assistant settings are shared globally or stored per workspace
|
|
110
|
+
|
|
111
|
+
Those are not the same thing.
|
|
112
|
+
|
|
113
|
+
The assistant UI can live on one surface while its settings UI lives somewhere else. That is exactly what we want in this chapter.
|
|
114
|
+
|
|
115
|
+
Here is the target shape:
|
|
116
|
+
|
|
117
|
+
| Assistant runtime | Runtime surface | Settings surface | Config scope | Meaning |
|
|
118
|
+
| --- | --- | --- | --- | --- |
|
|
119
|
+
| Console assistant | `console` | `console` | `global` | One operator assistant for the whole app, configured in the operator surface itself |
|
|
120
|
+
| Admin assistant | `admin` | `console` | `global` | Workspace-admin assistant UI, but centrally configured by app operators |
|
|
121
|
+
| App assistant | `app` | `admin` | `workspace` | Member-facing assistant, configured per workspace from that workspace's admin settings |
|
|
122
|
+
|
|
123
|
+
That table is the heart of the chapter.
|
|
124
|
+
|
|
125
|
+
JSKIT is not forcing every assistant to be configured where it runs. It lets you choose the governance model that fits the surface.
|
|
126
|
+
|
|
127
|
+
## Registering the three assistant surfaces
|
|
128
|
+
|
|
129
|
+
Set an AI key in your shell first if you already have one:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
OPENAI_API_KEY=...
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Then run:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx jskit generate assistant setup \
|
|
139
|
+
--surface console \
|
|
140
|
+
--settings-surface console \
|
|
141
|
+
--config-scope global \
|
|
142
|
+
--ai-provider openai \
|
|
143
|
+
--ai-api-key "$OPENAI_API_KEY"
|
|
144
|
+
|
|
145
|
+
npx jskit generate assistant setup \
|
|
146
|
+
--surface admin \
|
|
147
|
+
--settings-surface console \
|
|
148
|
+
--config-scope global \
|
|
149
|
+
--ai-provider openai \
|
|
150
|
+
--ai-api-key "$OPENAI_API_KEY"
|
|
151
|
+
|
|
152
|
+
npx jskit generate assistant setup \
|
|
153
|
+
--surface app \
|
|
154
|
+
--settings-surface admin \
|
|
155
|
+
--config-scope workspace \
|
|
156
|
+
--ai-provider openai \
|
|
157
|
+
--ai-api-key "$OPENAI_API_KEY"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
These commands do **not** create any pages yet. They only register three assistant runtime surfaces and write their config blocks into the app.
|
|
161
|
+
|
|
162
|
+
You can also leave `--ai-api-key` empty if you want to scaffold everything first and wire the key into `.env` later. The assistant pages will still exist, but the actual AI calls will stay unusable until the key is set.
|
|
163
|
+
|
|
164
|
+
The important `setup` options are:
|
|
165
|
+
|
|
166
|
+
- `--surface`
|
|
167
|
+
- the runtime surface that will host the assistant UI
|
|
168
|
+
- `--settings-surface`
|
|
169
|
+
- the surface that will host the assistant settings screen
|
|
170
|
+
- `--config-scope`
|
|
171
|
+
- `global` or `workspace`
|
|
172
|
+
- `--ai-provider`
|
|
173
|
+
- which AI backend family this assistant surface should use
|
|
174
|
+
- `--ai-api-key`
|
|
175
|
+
- the API key for that assistant surface
|
|
176
|
+
- `--ai-base-url`
|
|
177
|
+
- an optional provider-compatible endpoint override
|
|
178
|
+
- `--ai-timeout-ms`
|
|
179
|
+
- the request timeout for that assistant surface
|
|
180
|
+
- `--ai-config-prefix`
|
|
181
|
+
- an optional override for the env/config prefix
|
|
182
|
+
- if you omit it, JSKIT derives a prefix such as `CONSOLE_ASSISTANT` or `APP_ASSISTANT`
|
|
183
|
+
|
|
184
|
+
<DocsTerminalTip label="Important" title="Workspace Scope Needs Workspace Surfaces">
|
|
185
|
+
`--config-scope workspace` only works when **both** of these surfaces require a workspace:
|
|
186
|
+
|
|
187
|
+
- the runtime surface
|
|
188
|
+
- the settings surface
|
|
189
|
+
|
|
190
|
+
That is why the chapter uses:
|
|
191
|
+
|
|
192
|
+
- `app` configured from `admin` with `workspace`
|
|
193
|
+
|
|
194
|
+
but keeps:
|
|
195
|
+
|
|
196
|
+
- `admin` configured from `console` with `global`
|
|
197
|
+
|
|
198
|
+
`console` is a global surface. It does not carry a workspace slug, so it cannot host a workspace-scoped assistant settings flow.
|
|
199
|
+
</DocsTerminalTip>
|
|
200
|
+
|
|
201
|
+
## How assistant tools actually work
|
|
202
|
+
|
|
203
|
+
This is the most important conceptual point in the whole assistant stack:
|
|
204
|
+
|
|
205
|
+
The assistant does **not** automatically get access to "the backend" or to "all permission-guarded actions."
|
|
206
|
+
|
|
207
|
+
What it really gets is a filtered **tool catalog** built from normal JSKIT actions.
|
|
208
|
+
|
|
209
|
+
For an action to become an assistant tool, all of these must be true:
|
|
210
|
+
|
|
211
|
+
- it is registered as a real JSKIT action
|
|
212
|
+
- its `channels` include `"automation"`
|
|
213
|
+
- it has both an input schema and an output schema
|
|
214
|
+
- it is allowed on the current surface
|
|
215
|
+
- the current actor is allowed to execute it
|
|
216
|
+
- it is not hidden by the assistant surface config
|
|
217
|
+
|
|
218
|
+
So the assistant is never discovering methods by reflection and it is never seeing the entire service layer. It only sees a deliberate action-backed contract.
|
|
219
|
+
|
|
220
|
+
### Making an action available to the assistant
|
|
221
|
+
|
|
222
|
+
The normal pattern is:
|
|
223
|
+
|
|
224
|
+
1. define a normal JSKIT action
|
|
225
|
+
2. put it on the `automation` channel
|
|
226
|
+
3. give it real input and output schemas
|
|
227
|
+
4. optionally give it a better assistant-facing description
|
|
228
|
+
|
|
229
|
+
For example:
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
{
|
|
233
|
+
id: "workspace.members.invite",
|
|
234
|
+
domain: "workspace",
|
|
235
|
+
version: 1,
|
|
236
|
+
kind: "command",
|
|
237
|
+
channels: ["automation"],
|
|
238
|
+
surfaces: ["admin"],
|
|
239
|
+
permission: {
|
|
240
|
+
require: "all",
|
|
241
|
+
permissions: ["workspace.members.invite"]
|
|
242
|
+
},
|
|
243
|
+
inputValidator: {
|
|
244
|
+
schema: {
|
|
245
|
+
type: "object",
|
|
246
|
+
properties: {
|
|
247
|
+
email: { type: "string" }
|
|
248
|
+
},
|
|
249
|
+
required: ["email"],
|
|
250
|
+
additionalProperties: false
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
outputValidator: {
|
|
254
|
+
schema: {
|
|
255
|
+
type: "object",
|
|
256
|
+
properties: {
|
|
257
|
+
ok: { type: "boolean" }
|
|
258
|
+
},
|
|
259
|
+
required: ["ok"],
|
|
260
|
+
additionalProperties: false
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
extensions: {
|
|
264
|
+
assistant: {
|
|
265
|
+
description: "Invite a member into the current workspace."
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
That does two things at once:
|
|
272
|
+
|
|
273
|
+
- it stays a normal JSKIT action
|
|
274
|
+
- it becomes eligible for assistant exposure
|
|
275
|
+
|
|
276
|
+
If you leave out `channels: ["automation"]`, the assistant will not see it.
|
|
277
|
+
|
|
278
|
+
If you leave out the schemas, the assistant will not see it.
|
|
279
|
+
|
|
280
|
+
So the assistant layer is intentionally strict. It only exposes actions with a stable machine-readable contract.
|
|
281
|
+
|
|
282
|
+
### Permissions still matter
|
|
283
|
+
|
|
284
|
+
This is the next crucial point:
|
|
285
|
+
|
|
286
|
+
The assistant only sees tools that the current actor could execute normally.
|
|
287
|
+
|
|
288
|
+
So if an action says:
|
|
289
|
+
|
|
290
|
+
```js
|
|
291
|
+
permission: {
|
|
292
|
+
require: "all",
|
|
293
|
+
permissions: ["workspace.members.invite"]
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
then a user who does **not** have `workspace.members.invite` does not merely get a later failure dialog. That tool is filtered out of the assistant's available tool list before the request is sent to the model.
|
|
298
|
+
|
|
299
|
+
That means two users on the same surface can get different assistant capabilities, because their permission sets are different.
|
|
300
|
+
|
|
301
|
+
This is an important mental model:
|
|
302
|
+
|
|
303
|
+
- normal action permissions still remain the source of truth
|
|
304
|
+
- the assistant is a client of that action system, not a bypass around it
|
|
305
|
+
|
|
306
|
+
### Surface rules still matter too
|
|
307
|
+
|
|
308
|
+
Actions can also be restricted to specific surfaces.
|
|
309
|
+
|
|
310
|
+
If an action only lists:
|
|
311
|
+
|
|
312
|
+
```js
|
|
313
|
+
surfaces: ["admin"]
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
then it can appear in the `admin` assistant but not in the `console` assistant or the `app` assistant.
|
|
317
|
+
|
|
318
|
+
So tool exposure is filtered by **both**:
|
|
319
|
+
|
|
320
|
+
- who the user is
|
|
321
|
+
- where the assistant is running
|
|
322
|
+
|
|
323
|
+
That is exactly why this chapter's three-assistant setup is interesting. The three assistants can share some actions but differ on others because they do not all run on the same surface.
|
|
324
|
+
|
|
325
|
+
### How to hide actions even if they qualify
|
|
326
|
+
|
|
327
|
+
There is one more layer on top of action metadata.
|
|
328
|
+
|
|
329
|
+
Per-surface assistant server config can still hide tools intentionally.
|
|
330
|
+
|
|
331
|
+
The relevant config keys are:
|
|
332
|
+
|
|
333
|
+
- `barredActionIds`
|
|
334
|
+
- `toolSkipActionPrefixes`
|
|
335
|
+
|
|
336
|
+
For example:
|
|
337
|
+
|
|
338
|
+
```js
|
|
339
|
+
config.assistantServer.admin = {
|
|
340
|
+
aiConfigPrefix: "ADMIN_ASSISTANT",
|
|
341
|
+
barredActionIds: ["workspace.members.remove"],
|
|
342
|
+
toolSkipActionPrefixes: ["workspace.audit."]
|
|
343
|
+
};
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
That means:
|
|
347
|
+
|
|
348
|
+
- `workspace.members.remove` is hidden exactly
|
|
349
|
+
- any action whose id starts with `workspace.audit.` is hidden by prefix
|
|
350
|
+
|
|
351
|
+
This is useful when an action is valid in the app but you still do not want a given assistant surface to use it.
|
|
352
|
+
|
|
353
|
+
So the full exposure model is:
|
|
354
|
+
|
|
355
|
+
- action metadata says what *can* be a tool
|
|
356
|
+
- permission and surface context say what this user *may* use now
|
|
357
|
+
- assistant surface config says what this assistant surface *should still hide*
|
|
358
|
+
|
|
359
|
+
### How the assistant "knows" what it can do
|
|
360
|
+
|
|
361
|
+
The assistant runtime does not ask the model to invent tools on the fly.
|
|
362
|
+
|
|
363
|
+
Instead, for each request it builds the filtered tool set for the current:
|
|
364
|
+
|
|
365
|
+
- surface
|
|
366
|
+
- actor
|
|
367
|
+
- permission set
|
|
368
|
+
- workspace context
|
|
369
|
+
|
|
370
|
+
Then it sends two things into the AI request:
|
|
371
|
+
|
|
372
|
+
- the tool schemas themselves
|
|
373
|
+
- a system-prompt summary of the available tool names and contracts
|
|
374
|
+
|
|
375
|
+
So the model only sees the tools that survived all of the filtering above.
|
|
376
|
+
|
|
377
|
+
If a tool is unavailable:
|
|
378
|
+
|
|
379
|
+
- it is not described in the prompt
|
|
380
|
+
- it is not included in the tool schema payload
|
|
381
|
+
|
|
382
|
+
And even after that, actual execution still goes through the normal JSKIT action executor under the `automation` channel. So the assistant is constrained twice:
|
|
383
|
+
|
|
384
|
+
- first by tool-catalog filtering
|
|
385
|
+
- then by real action execution
|
|
386
|
+
|
|
387
|
+
### Workspace context is handled for you
|
|
388
|
+
|
|
389
|
+
Workspace-scoped tools get one more convenience.
|
|
390
|
+
|
|
391
|
+
If the current assistant is already running inside a workspace route, the tool catalog can hide the `workspaceSlug` field from the visible tool schema and inject it from the current request context during execution.
|
|
392
|
+
|
|
393
|
+
That means a workspace assistant can expose simpler tools to the model:
|
|
394
|
+
|
|
395
|
+
- "invite a member into the current workspace"
|
|
396
|
+
|
|
397
|
+
instead of always forcing the tool contract to say:
|
|
398
|
+
|
|
399
|
+
- "invite a member, and also provide the workspace slug again"
|
|
400
|
+
|
|
401
|
+
That makes the assistant contracts cleaner without weakening the actual workspace boundary.
|
|
402
|
+
|
|
403
|
+
## Generating the assistant pages
|
|
404
|
+
|
|
405
|
+
Now create the three runtime pages:
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
npx jskit generate assistant page console/assistant/index.vue
|
|
409
|
+
|
|
410
|
+
npx jskit generate assistant page \
|
|
411
|
+
w/[workspaceSlug]/admin/assistant/index.vue \
|
|
412
|
+
--name "Assistant"
|
|
413
|
+
|
|
414
|
+
npx jskit generate assistant page \
|
|
415
|
+
w/[workspaceSlug]/assistant/index.vue \
|
|
416
|
+
--name "Assistant"
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
These commands use the page path to decide where the assistant should live.
|
|
420
|
+
|
|
421
|
+
That gives you:
|
|
422
|
+
|
|
423
|
+
- `/console/assistant`
|
|
424
|
+
- `/w/[workspaceSlug]/admin/assistant`
|
|
425
|
+
- `/w/[workspaceSlug]/assistant`
|
|
426
|
+
|
|
427
|
+
Each generated file is intentionally thin. For example:
|
|
428
|
+
|
|
429
|
+
```vue
|
|
430
|
+
<template>
|
|
431
|
+
<AssistantSurfaceClientElement surface-id="console" />
|
|
432
|
+
</template>
|
|
433
|
+
|
|
434
|
+
<script setup>
|
|
435
|
+
import { AssistantSurfaceClientElement } from "@jskit-ai/assistant-runtime/client";
|
|
436
|
+
</script>
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
That is a good JSKIT pattern to notice:
|
|
440
|
+
|
|
441
|
+
- the app owns the route file
|
|
442
|
+
- the route file says which assistant surface it is exposing
|
|
443
|
+
- the reusable runtime element owns the heavy client behavior
|
|
444
|
+
|
|
445
|
+
The page generator also adds shell menu placements for those new routes, so the surfaces get real navigation entries without you hand-editing the menus.
|
|
446
|
+
|
|
447
|
+
In the `page` subcommand:
|
|
448
|
+
|
|
449
|
+
- the target file path decides the route location
|
|
450
|
+
- `--name` changes the generated menu label
|
|
451
|
+
- `--link-placement`, `--link-component-token`, and `--link-to` are optional overrides if you want to place the route link somewhere other than the generator's normal inferred target
|
|
452
|
+
|
|
453
|
+
## Generating the assistant settings pages
|
|
454
|
+
|
|
455
|
+
Now create the three settings pages:
|
|
456
|
+
|
|
457
|
+
```bash
|
|
458
|
+
npx jskit generate assistant settings-page \
|
|
459
|
+
console/settings/assistant/index.vue \
|
|
460
|
+
--surface console \
|
|
461
|
+
--link-placement console-settings:primary-menu \
|
|
462
|
+
--link-component-token local.main.ui.surface-aware-menu-link-item
|
|
463
|
+
|
|
464
|
+
npx jskit generate assistant settings-page \
|
|
465
|
+
console/settings/admin-assistant/index.vue \
|
|
466
|
+
--surface admin \
|
|
467
|
+
--name "Admin Assistant" \
|
|
468
|
+
--link-placement console-settings:primary-menu \
|
|
469
|
+
--link-component-token local.main.ui.surface-aware-menu-link-item
|
|
470
|
+
|
|
471
|
+
npx jskit generate assistant settings-page \
|
|
472
|
+
w/[workspaceSlug]/admin/workspace/settings/app-assistant/index.vue \
|
|
473
|
+
--surface app \
|
|
474
|
+
--name "App Assistant" \
|
|
475
|
+
--link-placement admin-settings:primary-menu \
|
|
476
|
+
--link-component-token local.main.ui.surface-aware-menu-link-item
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
This is the part that often trips people up, so read the rule carefully:
|
|
480
|
+
|
|
481
|
+
- the **target file path** decides where the settings page lives
|
|
482
|
+
- `--surface` decides **which assistant runtime surface that page configures**
|
|
483
|
+
|
|
484
|
+
So:
|
|
485
|
+
|
|
486
|
+
- `/console/settings/admin-assistant` configures the `admin` assistant
|
|
487
|
+
- `/w/[workspaceSlug]/admin/workspace/settings/app-assistant` configures the `app` assistant
|
|
488
|
+
|
|
489
|
+
That is not contradictory. It is the whole point of the design.
|
|
490
|
+
|
|
491
|
+
The generated settings pages are also thin wrappers:
|
|
492
|
+
|
|
493
|
+
```vue
|
|
494
|
+
<template>
|
|
495
|
+
<AssistantSettingsClientElement target-surface-id="app" />
|
|
496
|
+
</template>
|
|
497
|
+
|
|
498
|
+
<script setup>
|
|
499
|
+
import { AssistantSettingsClientElement } from "@jskit-ai/assistant-runtime/client";
|
|
500
|
+
</script>
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
The file path decides where the settings screen is opened. `target-surface-id` decides which assistant it edits.
|
|
504
|
+
|
|
505
|
+
The extra link options matter here too:
|
|
506
|
+
|
|
507
|
+
- `--link-placement`
|
|
508
|
+
- which settings menu outlet should receive the generated link
|
|
509
|
+
- `--link-component-token`
|
|
510
|
+
- which link component token should render that menu entry
|
|
511
|
+
- `--name`
|
|
512
|
+
- the label shown for the settings entry
|
|
513
|
+
|
|
514
|
+
That is why the chapter uses:
|
|
515
|
+
|
|
516
|
+
- `console-settings:primary-menu` for the two console-owned settings screens
|
|
517
|
+
- `admin-settings:primary-menu` for the workspace-admin-owned settings screen
|
|
518
|
+
|
|
519
|
+
## What to look at in the browser
|
|
520
|
+
|
|
521
|
+
Start both processes again:
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
npm run dev
|
|
525
|
+
npm run server
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
After sign-in, the app should now expose these assistant routes:
|
|
529
|
+
|
|
530
|
+
- `/console/assistant`
|
|
531
|
+
- `/w/your-personal-slug/admin/assistant`
|
|
532
|
+
- `/w/your-personal-slug/assistant`
|
|
533
|
+
|
|
534
|
+
And these settings routes:
|
|
535
|
+
|
|
536
|
+
- `/console/settings/assistant`
|
|
537
|
+
- `/console/settings/admin-assistant`
|
|
538
|
+
- `/w/your-personal-slug/admin/workspace/settings/app-assistant`
|
|
539
|
+
|
|
540
|
+
The most important thing to verify in the browser is the *relationship* between those pages.
|
|
541
|
+
|
|
542
|
+
- The `console` assistant runs in `console` and is configured in `console`.
|
|
543
|
+
- The `admin` assistant runs in the workspace `admin` surface, but its settings live in `console`, because this chapter treats it as centrally governed.
|
|
544
|
+
- The `app` assistant runs in the workspace `app` surface, and its settings live in workspace `admin`, because this chapter treats it as a workspace-owned assistant.
|
|
545
|
+
|
|
546
|
+
That gives the app two different governance models at the same time:
|
|
547
|
+
|
|
548
|
+
- app-wide operator-owned assistant config
|
|
549
|
+
- per-workspace assistant config
|
|
550
|
+
|
|
551
|
+
If you left the AI key empty, the pages and settings screens will still exist, but the assistant itself will not become useful until the AI key is filled into `.env`.
|
|
552
|
+
|
|
553
|
+
## What `assistant-runtime` and `assistant` add to the app
|
|
554
|
+
|
|
555
|
+
This chapter changes more files than the realtime chapter, but the changes are still easy to read if you keep the runtime/generator split in mind.
|
|
556
|
+
|
|
557
|
+
### `config/public.js` maps assistant runtime surfaces
|
|
558
|
+
|
|
559
|
+
After the three `setup` commands, `config/public.js` contains:
|
|
560
|
+
|
|
561
|
+
```js
|
|
562
|
+
config.assistantSurfaces.console = {
|
|
563
|
+
settingsSurfaceId: "console",
|
|
564
|
+
configScope: "global"
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
config.assistantSurfaces.admin = {
|
|
568
|
+
settingsSurfaceId: "console",
|
|
569
|
+
configScope: "global"
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
config.assistantSurfaces.app = {
|
|
573
|
+
settingsSurfaceId: "admin",
|
|
574
|
+
configScope: "workspace"
|
|
575
|
+
};
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
This is the public routing contract for assistants.
|
|
579
|
+
|
|
580
|
+
For each assistant runtime surface, it answers:
|
|
581
|
+
|
|
582
|
+
- where is this assistant configured?
|
|
583
|
+
- is that configuration global or workspace-specific?
|
|
584
|
+
|
|
585
|
+
### `config/server.js` chooses the env/config prefix for each assistant
|
|
586
|
+
|
|
587
|
+
The same `setup` commands also write:
|
|
588
|
+
|
|
589
|
+
```js
|
|
590
|
+
config.assistantServer.console = {
|
|
591
|
+
aiConfigPrefix: "CONSOLE_ASSISTANT"
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
config.assistantServer.admin = {
|
|
595
|
+
aiConfigPrefix: "ADMIN_ASSISTANT"
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
config.assistantServer.app = {
|
|
599
|
+
aiConfigPrefix: "APP_ASSISTANT"
|
|
600
|
+
};
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
That is what lets one app host several assistants at once without their AI settings colliding.
|
|
604
|
+
|
|
605
|
+
### `.env` gains one AI block per assistant surface
|
|
606
|
+
|
|
607
|
+
The app now gets env keys such as:
|
|
608
|
+
|
|
609
|
+
```dotenv
|
|
610
|
+
CONSOLE_ASSISTANT_AI_PROVIDER=openai
|
|
611
|
+
CONSOLE_ASSISTANT_AI_API_KEY=
|
|
612
|
+
CONSOLE_ASSISTANT_AI_BASE_URL=
|
|
613
|
+
CONSOLE_ASSISTANT_AI_TIMEOUT_MS=120000
|
|
614
|
+
|
|
615
|
+
ADMIN_ASSISTANT_AI_PROVIDER=openai
|
|
616
|
+
ADMIN_ASSISTANT_AI_API_KEY=
|
|
617
|
+
ADMIN_ASSISTANT_AI_BASE_URL=
|
|
618
|
+
ADMIN_ASSISTANT_AI_TIMEOUT_MS=120000
|
|
619
|
+
|
|
620
|
+
APP_ASSISTANT_AI_PROVIDER=openai
|
|
621
|
+
APP_ASSISTANT_AI_API_KEY=
|
|
622
|
+
APP_ASSISTANT_AI_BASE_URL=
|
|
623
|
+
APP_ASSISTANT_AI_TIMEOUT_MS=120000
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
That is why `setup` is a per-surface command. Each assistant runtime surface gets its own AI configuration namespace.
|
|
627
|
+
|
|
628
|
+
### `migrations/` gains assistant schema files
|
|
629
|
+
|
|
630
|
+
Installing `assistant-runtime` also adds schema files for:
|
|
631
|
+
|
|
632
|
+
- assistant configuration
|
|
633
|
+
- assistant transcripts
|
|
634
|
+
|
|
635
|
+
Those are shared runtime tables. The generator does not create them. That is the runtime package's job.
|
|
636
|
+
|
|
637
|
+
### `src/pages/...` gains thin runtime and settings wrappers
|
|
638
|
+
|
|
639
|
+
After the chapter, the app owns several new route files under `src/pages/...`.
|
|
640
|
+
|
|
641
|
+
The important point is that they are all small wrappers around reusable client elements:
|
|
642
|
+
|
|
643
|
+
- runtime pages use `AssistantSurfaceClientElement`
|
|
644
|
+
- settings pages use `AssistantSettingsClientElement`
|
|
645
|
+
|
|
646
|
+
That keeps the app-owned routing explicit without copying the runtime logic into every page file.
|
|
647
|
+
|
|
648
|
+
### `src/placement.js` grows assistant links in several menus
|
|
649
|
+
|
|
650
|
+
The page generator and settings-page generator also append placement entries.
|
|
651
|
+
|
|
652
|
+
That is how the assistant routes show up in:
|
|
653
|
+
|
|
654
|
+
- the main shell menus for `console`, `admin`, and `app`
|
|
655
|
+
- the `console` settings menu
|
|
656
|
+
- the workspace `admin` settings menu
|
|
657
|
+
|
|
658
|
+
So the generator is not only creating route files. It is also wiring those routes into the right existing shell and settings outlets.
|
|
659
|
+
|
|
660
|
+
## Under the hood
|
|
661
|
+
|
|
662
|
+
`assistant-runtime` owns the shared assistant engine:
|
|
663
|
+
|
|
664
|
+
- server routes
|
|
665
|
+
- database tables
|
|
666
|
+
- client runtime
|
|
667
|
+
- config loading for each assistant surface
|
|
668
|
+
|
|
669
|
+
The `assistant` generator then writes the app-specific shape around that engine:
|
|
670
|
+
|
|
671
|
+
- which assistant surfaces exist
|
|
672
|
+
- where their runtime pages live
|
|
673
|
+
- where their settings pages live
|
|
674
|
+
- which menu outlets should link to them
|
|
675
|
+
|
|
676
|
+
The runtime uses the current surface and, when needed, the current workspace route context to resolve the right assistant configuration.
|
|
677
|
+
|
|
678
|
+
That is also why impossible combinations are rejected early. If you ask for workspace-scoped settings on a non-workspace surface, JSKIT fails at generation time instead of letting the app drift into a broken setup.
|
|
679
|
+
|
|
680
|
+
## Summary
|
|
681
|
+
|
|
682
|
+
This chapter adds a lot of capability without inventing a new monolithic "assistant mode."
|
|
683
|
+
|
|
684
|
+
- `assistant-runtime` installs the shared assistant engine
|
|
685
|
+
- `assistant setup` registers one assistant runtime surface at a time
|
|
686
|
+
- `assistant page` decides where each assistant UI lives
|
|
687
|
+
- `assistant settings-page` decides where each assistant is configured
|
|
688
|
+
|
|
689
|
+
By the end of the chapter, the app has:
|
|
690
|
+
|
|
691
|
+
- one global operator assistant in `console`
|
|
692
|
+
- one workspace-admin assistant governed from `console`
|
|
693
|
+
- one workspace-facing assistant governed from `admin`
|
|
694
|
+
|
|
695
|
+
That is a good example of JSKIT's surface model paying off. The assistant is not tied to one hard-coded area of the app. It can live and be governed differently on different surfaces.
|