@jskit-ai/agent-docs 0.1.353 → 0.1.354

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 (54) hide show
  1. package/guide/agent/app-extras/assistant.md +70 -0
  2. package/guide/agent/app-setup/authentication.md +151 -2
  3. package/guide/agent/app-setup/database-layer.md +9 -0
  4. package/guide/agent/app-setup/service-keys.md +103 -0
  5. package/guide/agent/app-setup/upgrading-jskit.md +11 -2
  6. package/guide/agent/framework/data-access.md +13 -0
  7. package/guide/agent/framework/typed-features.md +10 -5
  8. package/guide/agent/index.md +2 -0
  9. package/package.json +1 -1
  10. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  11. package/patterns/minimal-foundation/example/package.json +3 -3
  12. package/patterns/shell-foundation/example/package.json +4 -4
  13. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  14. package/reference/autogen/PATTERN_INDEX.md +49 -38
  15. package/reference/autogen/packages/assistant-core.md +44 -8
  16. package/reference/autogen/packages/assistant-runtime.md +25 -0
  17. package/reference/autogen/packages/auth-core.md +4 -0
  18. package/reference/autogen/packages/auth-provider-local-core.md +13 -0
  19. package/reference/autogen/packages/auth-web.md +60 -16
  20. package/reference/autogen/packages/crud-core.md +3 -1
  21. package/reference/autogen/packages/database-runtime.md +1 -0
  22. package/reference/autogen/packages/http-web.md +1 -0
  23. package/reference/autogen/packages/realtime.md +2 -1
  24. package/reference/autogen/packages/resource-runtime.md +9 -0
  25. package/reference/autogen/packages/shell-web.md +35 -0
  26. package/reference/autogen/tooling/jskit-catalog.md +13 -6
  27. package/reference/autogen/tooling/testUtils.md +1 -0
  28. package/skills/jskit/references/data-access.md +13 -0
  29. package/skills/jskit/references/database-layer.md +9 -0
  30. package/skills/jskit/references/heuristics/row-policies.md +1 -1
  31. package/skills/jskit/references/heuristics/ui-testing.md +3 -3
  32. package/skills/jskit/references/pattern-index.md +49 -38
  33. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
  34. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
  35. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  36. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
  37. package/skills/jskit/references/patterns/auth/auth-surface/PATTERN.md +3 -0
  38. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  39. package/skills/jskit/references/patterns/auth/own-design-sign-in/PATTERN.md +141 -0
  40. package/skills/jskit/references/patterns/auth/own-design-sign-in/example/src/components/ConfirmItsYouDialog.vue +182 -0
  41. package/skills/jskit/references/patterns/auth/own-design-sign-in/example/src/theme/tokens.css +35 -0
  42. package/skills/jskit/references/patterns/auth/own-design-sign-in/example/src/views/auth/LoginView.vue +473 -0
  43. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  44. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -5
  45. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
  46. package/skills/jskit/references/patterns/crud/crud-screen-set/example/books/BookListPage.vue +1 -1
  47. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
  48. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
  49. package/skills/jskit/references/patterns/realtime/realtime-application/PATTERN.md +5 -1
  50. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  51. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  52. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
  53. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
  54. package/skills/jskit/references/typed-features.md +10 -5
@@ -778,6 +778,36 @@ action's own logs, events and writes stay the app's; `isExecutionLogged(context)
778
778
  from `@jskit-ai/kernel/server/actions` is false during an unsaved call, so the
779
779
  action and its policy can keep their own logs quiet too.
780
780
 
781
+ ### Action hints for clients that ask first
782
+
783
+ A client that asks a person before a change, such as an MCP client, reads three
784
+ hints from each tool. A `query` action is read-only. A command is a change; it
785
+ says more when it declares:
786
+
787
+ ```js
788
+ extensions: {
789
+ assistant: {
790
+ destructive: true, // removes or overwrites what cannot be had back
791
+ sendsOutside: true // reaches people or systems outside the app: mail, a payment, another service
792
+ }
793
+ }
794
+ ```
795
+
796
+ Any value other than `true` or `false` stops the catalogue with an error naming
797
+ the action. A JSON:API CRUD feature's generated delete is destructive; its list,
798
+ view, create and update are not, unless the feature says so for a table whose
799
+ every change a client should ask about first:
800
+
801
+ ```js
802
+ defineCrudFeature({ crud, surface: "admin", assistantHints: { create: { destructive: true }, update: { destructive: true } } });
803
+ ```
804
+
805
+ `assistantHints` names only the feature's own create, update or delete, each
806
+ with `destructive` or `sendsOutside` as `true` or `false`; anything else stops
807
+ the server, naming the hint. Its custom actions declare hints in their own
808
+ `extensions`, and one without an assistant description is described by its
809
+ route's `summary`, so a client reads what its route says it does.
810
+
781
811
  ### Database surface conversation lifecycle
782
812
 
783
813
  The client receives answer text incrementally and shows working status before
@@ -981,3 +1011,43 @@ one provider-error conversation, and verify global or cross-workspace isolation.
981
1011
  Do not add a second model client beside the runtime, copy its repositories or
982
1012
  routes, infer a surface, store keys in source, or keep generator markers,
983
1013
  questionnaire answers, receipts, or provenance.
1014
+
1015
+ ## MCP endpoint
1016
+
1017
+ `AssistantMcpFeature` from `@jskit-ai/assistant-runtime/server` serves the
1018
+ actions of one surface as the tools of a remote MCP server, at `POST /api/mcp`,
1019
+ or `POST /api/w/:workspaceSlug/mcp` for a workspace surface. It is one of
1020
+ assistant-runtime's server providers and serves nothing until the app names the
1021
+ surface:
1022
+
1023
+ ```js
1024
+ config.assistantMcp = { surfaceId: "admin" };
1025
+ ```
1026
+
1027
+ Its callers are other applications' servers. Each POST signs in by a
1028
+ [service key](/guide/app-setup/service-keys) and names the user it acts as
1029
+ (`Authorization: Bearer <key>` and `Act-As-User: <user id or email>`), never by
1030
+ a browser's cookies, and the answer names that user's id in `Acting-As-User`.
1031
+ `assistantMcp.rateLimit` (`{ max, timeWindow }`, as a route's) limits the calls
1032
+ from one address, from which a key's server calls for all its users.
1033
+
1034
+ Each POST carries one JSON-RPC message (`initialize`, `ping`, `tools/list`,
1035
+ `tools/call`) and gets its answer as JSON; a notification gets `202` with no
1036
+ body. The endpoint keeps no session and opens no stream: `GET` and `DELETE`
1037
+ answer `405`. Every message runs as the user the key acts as, through
1038
+ the endpoint's own action (`assistant.mcp.request`), so a tool sees the same
1039
+ permissions, surface and workspace as that surface's HTTP routes, and a person
1040
+ lists and calls only what they may run.
1041
+
1042
+ Every automation action of the surface is a tool of its own, named like the
1043
+ assistant's tools (`crud.ports.list` is `crud_ports_list`), with its input schema
1044
+ and its hints as MCP annotations (`readOnlyHint`, `destructiveHint`,
1045
+ `openWorldHint`). Unlike the in-app assistant, there are no discovery tools, and
1046
+ an action without an output schema is a tool too: it answers as it ran, as its
1047
+ route does. Unsaved actions and streams are never tools here, nor are the
1048
+ actions that change how the person signs in (`auth.*` and `settings.security.*`:
1049
+ signing out, their sessions, sign-in methods and linked providers), since a
1050
+ key acts as the person and their sign-in stays theirs. `tools/list` pages
1051
+ 50 tools at a time. The surface's `assistantServer` barred ids and skipped
1052
+ prefixes apply too, and a result is held to 256 KiB unless the surface sets
1053
+ `maxToolResultBytes`.
@@ -27,6 +27,10 @@ npm install @jskit-ai/auth-provider-oidc-core @jskit-ai/auth-web
27
27
  The dependency graph supplies `@jskit-ai/auth-core`. Do not install two
28
28
  providers for the same `auth.service` capability.
29
29
 
30
+ With local auth, another application's server can also call the app's bearer
31
+ routes as one of its users at a time, with a service key an administrator
32
+ makes: see [Service keys](/guide/app-setup/service-keys).
33
+
30
34
  ## Provider ownership
31
35
 
32
36
  The selected provider owns identity verification and sessions. The application
@@ -299,7 +303,9 @@ const refund = () => run(() => api.refund(orderId));
299
303
 
300
304
  `isSecondFactorRequired(error)` from `@jskit-ai/auth-core/shared/authSecondFactor`
301
305
  tells that refusal apart elsewhere, such as a page that asks for the second
302
- factor before it shows anything.
306
+ factor before it shows anything. An app with its own design system builds the
307
+ prompt and the settings in its own look on the composables behind these
308
+ components, as "Sign-in screens in an app's own design" below says.
303
309
 
304
310
  **Codes.** A code is accepted within one 30-second step either side of the
305
311
  server's clock, and only once: no code of an accepted step or an earlier one
@@ -325,6 +331,25 @@ an application that keeps an audit log installs the
325
331
  `auth.local.second-factor-events` capability, a function given each event after
326
332
  it is stored. Without one, local auth logs them.
327
333
 
334
+ **A code for an account the application names.** A caller with no session of
335
+ the account, such as a command signed in with an API key that must show its
336
+ creator's code before it answers, asks `auth.service`'s
337
+ `verifySecondFactorOf({ userId, proof })`, `proof` being `{ code }` or
338
+ `{ recoveryCode }`. Whose account and when are the application's decision. It
339
+ is the session's own check: wrong codes through either count toward the same
340
+ wait, and a code or recovery code accepted by one is used up for both. It
341
+ answers `{ verifiedAt, method, recoveryCodesLeft }` and marks no session.
342
+ Each refusal throws with its code: 404
343
+ `auth.local.secondFactor.accountNotFound` (no account has that id), 403
344
+ `auth.local.secondFactor.accountDisabled` (the account is disabled, even with
345
+ the right code), 409 `auth.local.secondFactor.notSetUp` (no confirmed
346
+ authenticator), 429
347
+ `auth.local.secondFactor.locked` (the account waits; `Retry-After` gives the
348
+ seconds), and 400 `codeInvalid`, `codeUsed`, `recoveryCodeInvalid` or
349
+ `proofRequired`. The application records its own event from the answer or the
350
+ refusal. Local auth's second-factor events for it say `via: "application"`,
351
+ with no request's address (`ip` ""); a session's own events have no `via`.
352
+
328
353
  ## How a session was signed in (local auth)
329
354
 
330
355
  An action that grants much (root on a machine, say) can ask more of the
@@ -1053,12 +1078,136 @@ page's own `?code=` or `?error=` still reads as a callback; name such a filter
1053
1078
  otherwise.
1054
1079
 
1055
1080
  Never restyle the views' own classes (`.login-screen`, `.auth-card`) or wrap
1056
- them in a frame of the app's; the brand slot is the one way in.
1081
+ them in a frame of the app's; the brand slot is the one way into the Material
1082
+ views. An app with its own design system writes its own views instead (below).
1057
1083
 
1058
1084
  Initial load errors stay inside the affected surface. Failed login, reset, and
1059
1085
  other transient mutations use the application toast and do not shift the form.
1060
1086
  Loading uses skeletons when content geometry is known.
1061
1087
 
1088
+ ## Sign-in screens in an app's own design
1089
+
1090
+ An app with its own design system writes its own sign-in screens with these
1091
+ composables; Material stays JSKIT's default. Each `Default*View` is a Material
1092
+ 3 rendering of one composable, and the composable holds everything the screen
1093
+ does. An app's own view calls the same composable, so it keeps every sign-in
1094
+ behavior with its own markup and CSS, and needs no Vuetify. Each comes from its
1095
+ own path, so a page loads only what it uses:
1096
+
1097
+ | Screen | Composable | Material view |
1098
+ |---|---|---|
1099
+ | Sign in, register, forgot password, one-time code, confirm your email | `useLoginView({ fallbackReturnTo })` from `@jskit-ai/auth-web/client/composables/useLoginView` | `DefaultLoginView` |
1100
+ | Password reset | `useResetPasswordView()` from `@jskit-ai/auth-web/client/composables/useResetPasswordView` | `DefaultResetPasswordView` |
1101
+ | Email change link | `useEmailChangeView()` from `@jskit-ai/auth-web/client/composables/useEmailChangeView` | `DefaultEmailChangeView` |
1102
+ | Sign out | `useSignOutView()` from `@jskit-ai/auth-web/client/composables/useSignOutView` | `DefaultSignOutView` |
1103
+ | A code or recovery code form | `useSecondFactorProof({ submit, onDone })` from `@jskit-ai/auth-web/client/composables/useSecondFactorProof` | `SecondFactorPrompt`, `SecondFactorDialog` |
1104
+ | The authenticator settings | `useSecondFactorSettings()` from `@jskit-ai/auth-web/client/composables/useSecondFactorSettings` | `SecondFactorSettings` |
1105
+ | A request asking for a fresh code | `useSecondFactorStepUp()` from `@jskit-ai/auth-web/client/composables/useSecondFactorStepUp` (also from `@jskit-ai/auth-web/client`) | `SecondFactorDialog` |
1106
+
1107
+ A proof form submits one of the second-factor requests from
1108
+ `@jskit-ai/auth-web/client/runtime/secondFactorRequests`: `verifySecondFactor`
1109
+ for a prompt, and `confirmSecondFactorSetup`,
1110
+ `replaceSecondFactorRecoveryCodes` and `removeSecondFactor` for the settings,
1111
+ which read with `readSecondFactor` and start with `startSecondFactorSetup`.
1112
+
1113
+ `useLoginView()` returns the mode (`isLogin`, `isRegister`, `isForgot`,
1114
+ `isOtp`, `isEmailConfirmationPending`) with `switchMode(mode)`, what the
1115
+ provider offers (`canUsePasswordLogin`, `canRegister`,
1116
+ `canRequestPasswordRecovery`, `canUseOtp`, `canUseOAuth`, ...), the fields as
1117
+ refs (`email`, `password`, `confirmPassword`, `otpCode`, `setupCode`,
1118
+ `confirmationCode`) with their error messages (`emailErrorMessages`, ...,
1119
+ shown once a field is touched or a submit was tried), `submitAuth`,
1120
+ `canSubmit`, `submitLabel`, `authTitle` and `authSubtitle`, the provider
1121
+ buttons (`oauthProviders`, `oauthProviderButtonLabel(provider)`,
1122
+ `startOAuthSignIn(id)`, `oauthRetryProvider`), the remembered account, the
1123
+ paused sign-in (`signInPausedMinutes`) and `redirectingSignedIn`, true while a
1124
+ browser already signed in is sent on, when the view shows no form. It handles
1125
+ invitations, the returnTo landing, a provider's callback and the session check
1126
+ on mount and on return to the page, as for `DefaultLoginView`. A refusal sets
1127
+ `errorMessage` (news such as a sent code sets `infoMessage`), which an own view
1128
+ shows beside the form; it also reaches the shell's error runtime, as from the
1129
+ Material view, whose host presents it. `oauthProviderIcon` is the Material view's
1130
+ icon alias; an own view picks its icon from `provider.id`. Text comes from
1131
+ `useJskitText()` of `@jskit-ai/kernel/client`, whose `jskit.auth.*` messages
1132
+ are the ones the Material views show, so the app's translations apply.
1133
+
1134
+ The `auth/auth-surface` pattern still supplies the auth surface, the pages,
1135
+ the brand and the managed-preview login; the `auth/own-design-sign-in` pattern
1136
+ replaces its `src/views/auth/LoginView.vue` with a plain HTML and CSS view on
1137
+ `useLoginView()` and adds a second-factor prompt in the app's design (a native
1138
+ `<dialog>` on `useSecondFactorProof()`) for `useSecondFactorStepUp()`. The app
1139
+ renders `AppBrand.vue` there in its own style, and keeps its colours in
1140
+ `src/theme/`.
1141
+
1142
+ ### JSKIT's screens with an app's own buttons, dialog and type
1143
+
1144
+ An app on Vuetify that keeps JSKIT's auth views, rather than writing its own,
1145
+ gives them its design system's button, dialog frame and text classes through
1146
+ shell-web's UI kit, `@jskit-ai/shell-web/client/ui`. It provides the kit once,
1147
+ before the app mounts, for example as one of `bootstrapClientShellApp()`'s
1148
+ `appPlugins` in `src/main.js`:
1149
+
1150
+ ```js
1151
+ import { provideShellUi } from "@jskit-ai/shell-web/client/ui";
1152
+ import AppButton from "./components/ui/AppButton.vue";
1153
+ import AppDialog from "./components/ui/AppDialog.vue";
1154
+
1155
+ const uiKit = {
1156
+ install: (app) =>
1157
+ provideShellUi(app, {
1158
+ Button: AppButton,
1159
+ Dialog: AppDialog,
1160
+ text: { title: "app-title", heading: "app-heading", body: "app-body", caption: "app-caption" }
1161
+ })
1162
+ };
1163
+ // appPlugins: [pinia, [VueQueryPlugin, { queryClient }], vuetify, uiKit]
1164
+ ```
1165
+
1166
+ The kit is partial: a role it leaves out, or a text role its `text` leaves out,
1167
+ stays Material 3's, and an app that provides no kit sees the Material screens
1168
+ as before. An unknown role or text role, a role that is not a Vue component or
1169
+ a text class that is not a string throws when the app provides it. A view
1170
+ reads the kit with `useShellUi()`, which returns `{ Button, Dialog, text }`.
1171
+
1172
+ `Button` draws every button of `DefaultLoginView`, `DefaultResetPasswordView`,
1173
+ `DefaultEmailChangeView`, `DefaultSignOutView`, `SecondFactorSettings` and the
1174
+ second-factor forms, with these props, and its label in its default slot:
1175
+
1176
+ | Prop | Values | Meaning |
1177
+ |---|---|---|
1178
+ | `emphasis` | `"high"`, `"medium"` (default), `"subtle"`, `"low"` | The screen's main action; a secondary action with a fill; a secondary action with an outline, such as one of several equal choices (the provider buttons); an action drawn as text alone. Material: flat, tonal, outlined, text. |
1179
+ | `tone` | `"accent"` (default), `"neutral"`, `"danger"` | Material: primary, secondary, error. |
1180
+ | `size` | `"default"`, `"large"` | A form's main action is `"large"`. |
1181
+ | `type` | `"button"` (default), `"submit"` | |
1182
+ | `disabled` | Boolean | |
1183
+ | `pending` | Boolean | The action is running. |
1184
+ | `block` | Boolean | The button takes its container's width. |
1185
+ | `href` | String | The button is a link. |
1186
+ | `icon` | String | A leading icon, as an icon alias (`"$google"`, `"$refresh"`); an app's button maps the aliases it draws. |
1187
+
1188
+ Other attributes reach the button: `class`, `data-testid`, `aria-*`, a
1189
+ `@click` listener, and `form`, which the step-up dialog's Confirm uses to
1190
+ submit the code form from the dialog's actions, so the app's button passes
1191
+ them to its `<button>` (Vue does this for a single root element).
1192
+
1193
+ `Dialog` is `SecondFactorDialog`'s frame: props `open` (Boolean) and `title`
1194
+ (the dialog's name and heading), the event `close` (Escape, a click outside or
1195
+ the frame's own close control; the view closes it and gives focus back to the
1196
+ control that sent the request), the body in its default slot and the actions,
1197
+ Cancel and then Confirm, in its `actions` slot. A native `<dialog>` opened with
1198
+ `showModal()` while `open`, named by its title, does all of it.
1199
+
1200
+ `text` maps each text role to a class: `title` (a screen's `h1`), `heading`,
1201
+ `subheading`, `strong`, `lead`, `body` and `caption`; Material's are
1202
+ `text-headline-medium`, `text-title-large`, `text-title-medium`,
1203
+ `text-title-small`, `text-body-large`, `text-body-medium` and
1204
+ `text-body-small`.
1205
+
1206
+ The fields, the Sign in and Register switch, the remember-me checkbox, the
1207
+ screen's card and its alerts stay Vuetify components drawn by the app's
1208
+ Vuetify theme, so this app still runs Vuetify; an app with no Vuetify writes
1209
+ its own screens on the composables above.
1210
+
1062
1211
  ## Verification
1063
1212
 
1064
1213
  Test successful and failed registration/login, sign-out, password reset,
@@ -391,6 +391,15 @@ the application's `knexfile.js`:
391
391
  a later run in the same tree restores them instead of replaying the
392
392
  migrations. Only the copies the run made are dropped, and none a session is
393
393
  connected to, such as another run's: the run names each copy it kept and why.
394
+ - A run that never reached its end (killed with `SIGKILL`, stopped at a
395
+ command's time limit, or on a machine that went down) leaves its copies. So
396
+ every run, a browser run's `prepare` module included, starts by dropping the
397
+ numbered copies of its database it will not make itself (`<name>_<count>` and
398
+ up), none a session is connected to, and its summary says so
399
+ (`dropped 1 numbered test database(s) earlier runs left (shop_test_7)`): a
400
+ killed run's copies last until the next run starts, never longer. Only names
401
+ JSKIT gives a copy count: `<name>_snapshot` and a project's own lettered
402
+ copies stay. Two runs at once on one database name still are not supported.
394
403
  - The snapshot holds the schema as the engine reports it and the rows the
395
404
  migrations wrote, including the migration ledger. On MySQL and MariaDB it is
396
405
  each table's `SHOW CREATE TABLE` and rows, in
@@ -0,0 +1,103 @@
1
+ <!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/app-setup/service-keys.md`. Do not edit manually. -->
2
+
3
+ # Service keys (local auth)
4
+
5
+ A service key lets another application's server, such as an assistant that
6
+ works for the people of a household or a team, call this app's bearer routes
7
+ (the [MCP endpoint](/guide/app-extras/assistant#mcp-endpoint) among them) as one
8
+ of the app's users at a time. Each call names the user it acts as and runs with
9
+ exactly that user's rights: what they may see and do, in their workspaces,
10
+ recorded as done by them through the key. The key never acts as itself, and no
11
+ person signs in anywhere for it.
12
+
13
+ ## Making a key
14
+
15
+ A key belongs to a dedicated service user, an ordinary local auth account
16
+ (enabled, with no password anyone uses) whose display name names the key in
17
+ what the app records, such as "Mercbot (Smith home)". An administrator makes the
18
+ key with the app's own tooling, which writes one row of the sessions store:
19
+
20
+ ```js
21
+ import { createServiceKeyRecord } from "@jskit-ai/auth-provider-local-core/server/lib/index";
22
+
23
+ const { key, record } = createServiceKeyRecord({ userId: serviceUser.id, days: 365 });
24
+ await backend.withTransaction((tx) => tx.sessions.create(record));
25
+ // Show `key` once: the store keeps only its hash.
26
+ ```
27
+
28
+ `record` is a session with purpose `service-key` (`SERVICE_KEY_PURPOSE`),
29
+ lasting `days` whole days (365 unless given, at most 3650). No table or column
30
+ changes: a key is a row of the table local auth already keeps sessions in.
31
+ Revoking that row (`tx.sessions.revoke(record.id)`) ends the key from the next
32
+ call, and so does disabling the service user, which ends all its keys. A key
33
+ never signs in a browser: cookie authentication takes only ordinary sessions.
34
+
35
+ ## Calling as a user
36
+
37
+ ```http
38
+ POST /api/w/acme/mcp
39
+ Authorization: Bearer svk_…
40
+ Act-As-User: 42
41
+ Content-Type: application/json
42
+ ```
43
+
44
+ `Act-As-User` names the user by id, or by email (any value with an `@`). An
45
+ email names a user only when exactly one enabled account has it: in an app
46
+ whose accounts may share an email, more than one enabled account with it names
47
+ no one, and the caller acts by the user's id instead. The MCP endpoint answers
48
+ the id it acted as in `Acting-As-User`, so a caller that started from an email
49
+ names the id from then on.
50
+
51
+ A backend answers every account with an email through
52
+ `users.findAllByEmail(email)`, the disabled ones too; one whose emails are
53
+ unique answers one or none. The file and database backends do; an app's own
54
+ backend adds it, and without it acting by email fails naming the fix.
55
+
56
+ Only routes that declare `config: { credentials: "bearer" }` take a key. Every
57
+ other route ignores `Authorization` and signs in by cookies alone, and a cookie
58
+ never signs in a bearer route, so a key never becomes a browser session and a
59
+ browser session never acts as anyone. auth-core holds both ways whatever the
60
+ provider answers: a route that takes cookies treats a bearer answer as signed
61
+ out, and a bearer route a cookie answer. A bearer route takes no CSRF token, since
62
+ it reads no cookies. The call's sign-in has no address and no second factor, so
63
+ a route that asks for either refuses it.
64
+
65
+ ## Refusals
66
+
67
+ Each refusal says why, with its code, and none falls back to the key's own
68
+ service user:
69
+
70
+ | Status | Code | When |
71
+ | --- | --- | --- |
72
+ | 401 | `auth.serviceKey.required` | No `Authorization` header. |
73
+ | 401 | `auth.serviceKey.invalid` | The key is unknown, revoked or expired, or its service user is disabled. |
74
+ | 403 | `auth.serviceKey.notServiceKey` | A person's own sign-in token instead of a key. |
75
+ | 400 | `auth.serviceKey.actAsRequired` | No `Act-As-User`. |
76
+ | 403 | `auth.serviceKey.actAsUnknown` | No user has that id or email. |
77
+ | 403 | `auth.serviceKey.actAsInactive` | That user is disabled. |
78
+ | 403 | `auth.serviceKey.actAsAmbiguous` | More than one enabled account has that email. |
79
+ | 403 | `auth.serviceKey.actAsSelf` | It names the key's own service user. |
80
+
81
+ A 401 carries `WWW-Authenticate: Bearer`, with `error="invalid_token"` when a
82
+ token was sent. The answer's body is the usual `{ error, code }`.
83
+
84
+ ## Who did it
85
+
86
+ The action context of a key's call has the user it acts as as `actor`, as any
87
+ signed-in request does, and the key as `actingVia: { userId, name }` (the
88
+ service user's id and display name). An app's audit records the actor as who
89
+ did it and `actingVia.name` as how, for example "Anna Smith, via Mercbot (Smith
90
+ home)".
91
+
92
+ ## A bearer route of your own
93
+
94
+ ```js
95
+ router.register("POST", "/api/books/export", {
96
+ auth: "required",
97
+ config: { credentials: "bearer" },
98
+ meta: { tags: ["books"], summary: "Export the books of the user the key acts as." }
99
+ }, handler);
100
+ ```
101
+
102
+ It needs an auth provider that signs bearer requests in: local auth does with
103
+ service keys; another provider's answer is refused.
@@ -92,6 +92,14 @@ with an unknown `email_verified_at` column. Read each package's CHANGELOG
92
92
  **Upgrading** section too, for the changes the application itself must make,
93
93
  such as a feature to register.
94
94
 
95
+ The updater compares each package's migration files with the ones its previous
96
+ version installed in `node_modules`. In a checkout that was never installed,
97
+ such as a fresh worktree, it compares through the previous `package-lock.json`
98
+ instead: a package at the same version adds none, and a package the lock lacked
99
+ adds all of its own. A package whose version moved has no earlier files there
100
+ to compare, so the updater names it (`<package> <previous> -> <new>`) rather
101
+ than counting its migrations as new, and says to run `npm run db:migrate`.
102
+
95
103
  ## Separately composed packages
96
104
 
97
105
  Pass each additional manifest explicitly to both commands:
@@ -254,8 +262,9 @@ application:
254
262
  `defineConfig(browserTestConfig({ testDir: "./tests/e2e", prepare: "tests/e2e/databases.js" }))`
255
263
  from `@jskit-ai/jskit-catalog/browser-tests`, with `server`, `build`, `env`
256
264
  or `port` only where its own differ from `node ./bin/server.js`,
257
- `npm run build` and 4173, `globalTimeout` only for a suite measured to
258
- need more than 20 minutes, and `actionTimeout` or `navigationTimeout` only
265
+ `npm run build` and free ports (`port` only for a port its host must
266
+ use), `globalTimeout` only for a suite measured to need more than its
267
+ default (80 worker-minutes, never under 20 minutes), and `actionTimeout` or `navigationTimeout` only
259
268
  for an action or page measured to need more than 15 or 30 seconds (a stale
260
269
  locator should fail in seconds, not minutes). Settings a config adds (projects, a globalSetup
261
270
  that proves the server's identity, `timezoneId`) spread over the result:
@@ -2143,6 +2143,19 @@ it. Check and judge, for each file:
2143
2143
  - its statements per row are still measured, as any write path's are: a batch
2144
2144
  of 200 rows costs about what a batch of 10 does.
2145
2145
 
2146
+ Tables the application's people define while it runs, which no table resource
2147
+ describes, can live in json-rest-api's AnyAPI storage, built in such an
2148
+ infrastructure module from `@jskit-ai/resource-runtime/server/anyapi`:
2149
+ `AnyapiRegistry`, `JsonRestApi`, `RestApiAnyapiKnexPlugin`, `RestApiPlugin`,
2150
+ `RowPolicyPlugin` and `ensureAnyApiSchema`, the very objects of the
2151
+ json-rest-api copy the runtime's handles run on. Import them from there and
2152
+ declare no json-rest-api in the application: json-rest-api knows the
2153
+ transactions `api.transaction` opened by identity, so an AnyAPI write given a
2154
+ handle's `txOptions.trx` joins that transaction only on the runtime's copy,
2155
+ and beside a second copy it fails with "transaction must be an active
2156
+ transaction from api.transaction". `npm run jskit:update` then moves the one
2157
+ copy with the catalog.
2158
+
2146
2159
  `jskit check` also fails:
2147
2160
 
2148
2161
  - a table with two table resources;
@@ -1086,11 +1086,14 @@ and Vitest's `maxWorkers` come from `testConcurrency()`.**
1086
1086
  - An application's `playwright.config.mjs` is
1087
1087
  `defineConfig(browserTestConfig({ testDir: "./tests/e2e" }))` from
1088
1088
  `@jskit-ai/jskit-catalog/browser-tests`. It builds the production frontend
1089
- once (reused while its sources are unchanged) and gives each worker its own
1090
- server, port and, through its `prepare` module, its own seeded database; a
1089
+ once (reused while the files it read are unchanged, so an edit to server
1090
+ code alone does not rebuild it) and gives each worker its own server, port
1091
+ and, through its `prepare` module, its own seeded database; a
1091
1092
  spec file's tests run in order in one worker. With `PLAYWRIGHT_BASE_URL`, the
1092
- tests use that managed target as its host serves it. Every run is bounded by
1093
- a `globalTimeout` (20 minutes, or the suite's own measured bound) and ends
1093
+ tests use that managed target as its host serves it. A local run takes free
1094
+ ports of its own, so two runs on one machine never meet. Every run is bounded
1095
+ by a `globalTimeout` (80 worker-minutes, never under 20 minutes: 20 on 4
1096
+ workers, 80 on one; or the suite's own measured bound) and ends
1094
1097
  with its 10 slowest tests. Each action and navigation is bounded too
1095
1098
  (`actionTimeout` 15 s, `navigationTimeout` 30 s): a stale locator should
1096
1099
  fail in seconds, not minutes, so a test waiting on something that never
@@ -1113,7 +1116,9 @@ and Vitest's `maxWorkers` come from `testConcurrency()`.**
1113
1116
  file's own bound in `test-time-bounds.json`, with the measurement in the
1114
1117
  commit that raises it; a file that got slow is fixed instead. A file still
1115
1118
  running at twice its bound, or sooner at ten times the time it last finished
1116
- in (at least two minutes), is stopped and fails the run by name, so the other
1119
+ all its tests in (at least two minutes; a run filtered by
1120
+ `--test-name-pattern`, `--test-skip-pattern` or `--test-only` records no
1121
+ time), is stopped and fails the run by name, so the other
1117
1122
  files still finish and report: look for what it leaves open (a server, child
1118
1123
  process, timer or socket) or a test without a timeout. A file with its own
1119
1124
  bound is stopped at twice that bound.
@@ -21,6 +21,8 @@ apply or adapt. It does not prescribe an agent host or project orchestrator.
21
21
  - [A more interesting shell](/guide/app-setup/a-more-interesting-shell)
22
22
  - [Authentication](/guide/app-setup/authentication)
23
23
  - [Sign in through an OIDC issuer](/guide/app-setup/sign-in-through-oidc-issuer)
24
+ - [Service keys](/guide/app-setup/service-keys): another application's server
25
+ calls this app as one of its users at a time
24
26
  - [Run an accounts hub](/guide/app-setup/run-an-accounts-hub)
25
27
  - [Database layer](/guide/app-setup/database-layer)
26
28
  - [Users](/guide/app-setup/users)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.353",
3
+ "version": "0.1.354",
4
4
  "description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
5
5
  "type": "module",
6
6
  "files": [
@@ -5,7 +5,7 @@
5
5
  "private": true,
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@jskit-ai/kernel": "0.2.33",
8
+ "@jskit-ai/kernel": "0.2.34",
9
9
  "json-rest-schema": "^1.0.20"
10
10
  },
11
11
  "exports": {
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.33",
37
+ "@jskit-ai/kernel": "0.2.34",
38
38
  "@jskit-ai/material-web": "0.1.10",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
@@ -44,13 +44,13 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.34",
47
+ "@jskit-ai/http-runtime": "0.2.35",
48
48
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
49
49
  "@vue/devtools-api": "^8.2.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/config-eslint": "0.1.252",
53
- "@jskit-ai/jskit-catalog": "0.2.105",
53
+ "@jskit-ai/jskit-catalog": "0.2.106",
54
54
  "@playwright/test": "1.61.1",
55
55
  "@vitejs/plugin-vue": "^6.0.7",
56
56
  "eslint": "^10.8.0",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.33",
37
+ "@jskit-ai/kernel": "0.2.34",
38
38
  "@jskit-ai/material-web": "0.1.10",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
@@ -44,14 +44,14 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.34",
48
- "@jskit-ai/shell-web": "0.2.50",
47
+ "@jskit-ai/http-runtime": "0.2.35",
48
+ "@jskit-ai/shell-web": "0.2.51",
49
49
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
50
50
  "@vue/devtools-api": "^8.2.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@jskit-ai/config-eslint": "0.1.252",
54
- "@jskit-ai/jskit-catalog": "0.2.105",
54
+ "@jskit-ai/jskit-catalog": "0.2.106",
55
55
  "@playwright/test": "1.61.1",
56
56
  "@vitejs/plugin-vue": "^6.0.7",
57
57
  "eslint": "^10.8.0",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "description": "App-local runtime composition and lightweight glue.",
11
11
  "dependencies": {
12
- "@jskit-ai/kernel": "0.2.33"
12
+ "@jskit-ai/kernel": "0.2.34"
13
13
  },
14
14
  "jskit": {
15
15
  "kind": "runtime",