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