@jskit-ai/agent-docs 0.1.341 → 0.1.343

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 (42) hide show
  1. package/guide/agent/app-setup/authentication.md +3 -1
  2. package/guide/agent/app-setup/database-layer.md +48 -0
  3. package/guide/agent/app-setup/upgrading-jskit.md +23 -0
  4. package/guide/agent/framework/environments.md +56 -16
  5. package/guide/agent/framework/material-3.md +3 -0
  6. package/package.json +1 -1
  7. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  8. package/patterns/minimal-foundation/example/package.json +3 -3
  9. package/patterns/shell-foundation/example/package.json +4 -4
  10. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  11. package/reference/autogen/KERNEL_MAP.md +5 -1
  12. package/reference/autogen/PATTERN_INDEX.md +38 -38
  13. package/reference/autogen/packages/assistant-runtime.md +12 -0
  14. package/reference/autogen/packages/auth-provider-local-db-core.md +20 -0
  15. package/reference/autogen/packages/auth-provider-oidc-core.md +4 -0
  16. package/reference/autogen/packages/console-core.md +4 -0
  17. package/reference/autogen/packages/database-runtime.md +15 -0
  18. package/reference/autogen/packages/kernel.md +5 -1
  19. package/reference/autogen/packages/oidc-issuer-core.md +4 -0
  20. package/reference/autogen/packages/rewarded-core.md +16 -0
  21. package/reference/autogen/packages/shell-web.md +1 -1
  22. package/reference/autogen/packages/users-core.md +4 -0
  23. package/reference/autogen/packages/workspaces-core.md +4 -0
  24. package/reference/autogen/tooling/jskit-catalog.md +1 -0
  25. package/skills/jskit/references/database-layer.md +48 -0
  26. package/skills/jskit/references/environments.md +56 -16
  27. package/skills/jskit/references/material-3.md +3 -0
  28. package/skills/jskit/references/pattern-index.md +38 -38
  29. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
  30. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
  31. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  32. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
  33. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  34. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  35. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -5
  36. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
  37. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
  38. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
  39. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  40. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  41. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
  42. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
@@ -378,7 +378,9 @@ that registered; in staging only to `STAGING_EMAIL_TO`, called with that
378
378
  address as `email` and the registered one as `originalEmail`, which its email
379
379
  should show (`markStagingEmail` from
380
380
  `@jskit-ai/kernel/server/runtime/appEnvironment` does), or not at all when
381
- `STAGING_EMAIL_TO` is unset; in development and test never. Where it is not
381
+ `STAGING_EMAIL_TO` is unset; on a staging server that real people use
382
+ (`STAGING_REACHES_REAL_PEOPLE=true`) to the address that registered, as in
383
+ production; in development and test never. Where it is not
382
384
  called, local auth logs each link for the person testing and keeps it out of
383
385
  the answer. So no code may depend on the sender having run, such as code that
384
386
  confirms a registration with the link its sender was given: in development,
@@ -244,6 +244,54 @@ relocation must retain its basename and be checked against both fresh and
244
244
  existing ledgers. Never drop valuable data or delete ledger entries to force
245
245
  a replay.
246
246
 
247
+ ### A new table takes the collation of the tables already there
248
+
249
+ MySQL and MariaDB create a table that names no character set or collation in
250
+ the database's default. A dump restored onto a server with another default
251
+ keeps each table's collation but takes the new database default, so a later
252
+ migration's new table no longer matches the tables it joins: comparing their
253
+ text fails with "Illegal mix of collations", and a foreign key between them is
254
+ refused (errno 150, "Foreign key constraint is incorrectly formed"). Up to
255
+ `@jskit-ai/jskit-catalog` 0.2.93, `auth_local_db_users_second_factors.cjs` failed
256
+ that way on such a database: it left an empty, unrecorded
257
+ `auth_local_second_factors` behind, and the migrations before it had recorded
258
+ their new tables in the new default, such as `auth_local_used_passes`.
259
+
260
+ Every JSKIT package migration that creates a table now creates it in the
261
+ collation of the existing tables, read from `information_schema`. Released
262
+ migrations stay as they are: each has a companion, the same name with
263
+ `-collation` before `.cjs`, which Knex sorts just before it (a `-` sorts before
264
+ `.`), so it runs first on every database that has not run it. The companion
265
+ calls `migrateInExistingCollation()` from
266
+ `@jskit-ai/database-runtime/server/tableCollationMigrations`, which runs the
267
+ released migration with each table it creates in the collation of the first
268
+ existing table of its list (the package's first table, then `users`, then
269
+ `auth_local_users`), and the released migration then finds its tables in place.
270
+ On PostgreSQL and SQLite, or before any of those tables exists, it does
271
+ nothing and the released migration runs as it did.
272
+
273
+ It also repairs what the database's default left, each only in the state it
274
+ measures, and changes nothing on a database whose tables are all in place, in
275
+ that collation, with their keys:
276
+
277
+ - an empty table of a migration Knex has not recorded, without the foreign key
278
+ that migration creates with it, is what a refused key left: it is dropped
279
+ and created again; with rows, the migration stops and changes nothing;
280
+ - a table of a recorded migration in another collation is converted when no
281
+ stored character can be lost (its text is in the same character set, or one
282
+ the target holds every character of, or it has no row), and otherwise the
283
+ migration stops and changes nothing; it then gains a missing key, unless rows
284
+ have no parent.
285
+
286
+ A new migration that creates a table calls `migrateInExistingCollation()` itself,
287
+ with its own file name and its table-creating `up`, so it needs no companion.
288
+ `tooling/jskit-catalog/test/tableCollationCompanions.test.js` fails for a table
289
+ migration that does neither, and names the released ones a companion cannot
290
+ serve: `payments_core_initial.cjs` and `connectors_core_initial.cjs` create
291
+ their tables without checking whether they exist, and `agent_initial.cjs` runs
292
+ on PostgreSQL only. Never change a database's default (`ALTER DATABASE`) to
293
+ make a migration pass: an application's own tables keep theirs.
294
+
247
295
  ## Seed data is not a migration
248
296
 
249
297
  Migrations establish schema and invariant framework data. Product fixtures,
@@ -430,3 +430,26 @@ naming the new one, and so does a preparation of test databases
430
430
  - `AUTH_LOCAL_FILE_PRODUCTION_ACK` is `AUTH_LOCAL_FILE_STAGING_OR_PRODUCTION_ACK`:
431
431
  the local file auth backend needs it set to `true` in staging and in
432
432
  production.
433
+
434
+ ## New tables in the collation of the existing ones
435
+
436
+ A MySQL or MariaDB database whose default collation differs from its tables',
437
+ such as a dump restored onto a server with another default, made JSKIT's
438
+ migrations up to the 0.2.93 catalog create each new table in that default.
439
+ `auth_local_db_users_second_factors` then failed (errno 150, "Foreign key
440
+ constraint is incorrectly formed") and left the database half-migrated: the
441
+ migrations before it recorded, `auth_local_used_passes` among them in the
442
+ database's default, and an empty, unrecorded `auth_local_second_factors`.
443
+
444
+ Update to the catalog after 0.2.93 and run `npm run db:migrate`; no repair by
445
+ hand. Each released migration that creates a table has a new companion,
446
+ `<name>-collation.cjs`, which runs first and creates its tables in the
447
+ collation of the existing tables, and repairs that state: the empty, unrecorded
448
+ `auth_local_second_factors` is created again with its key, a table recorded in
449
+ the database's default (`auth_local_used_passes`) is converted, keeping its
450
+ rows, and a second factors table that a second try recorded without its key
451
+ gets it. A database whose tables already match its default records the
452
+ companions and changes nothing. A table holding rows that a conversion could
453
+ not keep whole stops the migration and changes nothing, naming the table
454
+ ([Database layer](./database-layer.md#a-new-table-takes-the-collation-of-the-tables-already-there)).
455
+ Do not change the database's default to get past the failure.
@@ -17,7 +17,7 @@ builds, and staging and production set it to `production`.
17
17
  | --- | --- | --- | --- | --- | --- | --- |
18
18
  | `development` | a developer's machine, a session, a preview | logged | logged | sandbox only | allowed | "Development" |
19
19
  | `test` | automated test runs | logged | logged | sandbox only | allowed | "Test" |
20
- | `staging` | a copy on a server for checking the application before production | only to `STAGING_EMAIL_TO` and `STAGING_SMS_TO`; logged when unset | logged | sandbox only | refused | "Staging" |
20
+ | `staging` | a copy on a server for checking the application before production | only to `STAGING_EMAIL_TO` and `STAGING_SMS_TO`; logged when unset; sent when real people use it (`STAGING_REACHES_REAL_PEOPLE=true`) | logged | sandbox only | refused | "Staging" ("Staging · real people" when real people use it) |
21
21
  | `production` | the application serving real people | sent | sent | live | refused | none |
22
22
 
23
23
  The development shortcuts are dev sign-in (`AUTH_DEV_BYPASS_ENABLED`), cookies
@@ -33,14 +33,15 @@ for the emails it sends.
33
33
  The host sets `APP_ENV`; a request never chooses it. JSKIT's own commands set
34
34
  it where they own the run.
35
35
 
36
- | Who | `APP_ENV` | `NODE_ENV` | `STAGING_EMAIL_TO`, `STAGING_SMS_TO` |
37
- | --- | --- | --- | --- |
38
- | `npm run develop`, `npm run dev` on a developer's machine | `development`, set by the scripts | unset | unset |
39
- | A session or preview in an editor | `development` | unset | unset |
40
- | `jskit test` and the browser test servers | `test`, set by JSKIT | anything | unset |
41
- | A build-check machine that starts the packaged build to see it start and answer health | `staging` | `production` | unset, so everything is logged |
42
- | A staging server | `staging` | `production` | the testers' inbox and phone |
43
- | A production server | `production` | `production` | ignored |
36
+ | Who | `APP_ENV` | `NODE_ENV` | `STAGING_EMAIL_TO`, `STAGING_SMS_TO` | `STAGING_REACHES_REAL_PEOPLE` |
37
+ | --- | --- | --- | --- | --- |
38
+ | `npm run develop`, `npm run dev` on a developer's machine | `development`, set by the scripts | unset | unset | unset |
39
+ | A session or preview in an editor | `development` | unset | unset | unset |
40
+ | `jskit test` and the browser test servers | `test`, set by JSKIT | anything | unset | unset |
41
+ | A build-check machine that starts the packaged build to see it start and answer health | `staging` | `production` | unset, so everything is logged | unset |
42
+ | A staging server | `staging` | `production` | the testers' inbox and phone | unset |
43
+ | A staging server that real people use, while there is no production | `staging` | `production` | not used | `true`, set by the host |
44
+ | A production server | `production` | `production` | ignored | unset |
44
45
 
45
46
  A server started with `npm start` reads `APP_ENV` from its environment, or from
46
47
  `.env` (`APP_ENV=development` on a developer's machine; the foundations'
@@ -85,6 +86,12 @@ A server stops at startup, saying what to do, when:
85
86
  - A development-only setting is set in staging or production, for example
86
87
  `AUTH_LOCAL_RECOVERY_DEV_OUTPUT is for development only and APP_ENV is
87
88
  staging. Remove it from the staging environment.`
89
+ - `STAGING_REACHES_REAL_PEOPLE` is set outside staging: `STAGING_REACHES_REAL_PEOPLE
90
+ is set and APP_ENV is production. It says real people use a staging server,
91
+ so only APP_ENV=staging takes it: remove STAGING_REACHES_REAL_PEOPLE from the
92
+ production environment.` Any value but `true` is refused too:
93
+ `STAGING_REACHES_REAL_PEOPLE is "yes". Set it to true when real people use
94
+ this staging server, or leave it unset.`
88
95
 
89
96
  It then logs one line saying where it runs and what that means, such as
90
97
  `APP_ENV is staging: email goes only to qa@example.com (STAGING_EMAIL_TO), SMS
@@ -105,12 +112,39 @@ logs it, with what a tester needs, such as its link. Push notifications,
105
112
  webhooks and connector writes are always logged in staging, and live payments
106
113
  are refused there, as everywhere but production.
107
114
 
115
+ ## A staging server that real people use
116
+
117
+ Sometimes real people already use a staging server, because the application
118
+ has no production yet. Its host then sets `STAGING_REACHES_REAL_PEOPLE=true`
119
+ beside `APP_ENV=staging`, and email and SMS go to the people they are for:
120
+ `deliverMessage` sends each one to its recipient, unmarked (`originalTo` is
121
+ empty, so `markStagingEmail` leaves it as it is), and logs `Staging: the
122
+ password reset email to ada@example.com was sent to ada@example.com, since
123
+ real people use this staging (STAGING_REACHES_REAL_PEOPLE).` Everything else
124
+ stays as staging has it: `APP_ENV` is still `staging`, with its own settings
125
+ and databases; `STAGING_EMAIL_TO` and `STAGING_SMS_TO` are not used (the
126
+ startup line says so when they are set); push notifications, webhooks and
127
+ connector writes are logged; payments use the sandbox; development shortcuts
128
+ are refused. Every page names it in a second meta tag,
129
+ `jskit-staging-reaches-real-people`, and the banner reads "Staging · real
130
+ people" ("Staging that real people use: email and text messages reach the
131
+ people they are for, …").
132
+
133
+ The setting is the host's word, never the application's: only `true` means
134
+ anything, only `APP_ENV=staging` takes it, and a server refuses to start with
135
+ it in any other environment. An application decides nothing from it but who
136
+ receives its email and SMS, and reads it through
137
+ `stagingReachesRealPeople(env)` from
138
+ `@jskit-ai/kernel/shared/support/appEnvironment` when it sends some other way.
139
+
108
140
  ## What JSKIT does
109
141
 
110
142
  - Every HTML page the server sends, and every page the Vite development server
111
- sends, names its environment in a `jskit-app-environment` meta tag. The
112
- shell (`@jskit-ai/shell-web`) shows a small "Development", "Test" or
113
- "Staging" banner from it, with no application code, and none in production.
143
+ sends, names its environment in a `jskit-app-environment` meta tag (and,
144
+ on a staging server that real people use, `jskit-staging-reaches-real-people`
145
+ after it). The shell (`@jskit-ai/shell-web`) shows a small "Development",
146
+ "Test", "Staging" or "Staging · real people" banner from them, with no
147
+ application code, and none in production.
114
148
  The banner never takes a click or a tap. Screen readers read it as a note,
115
149
  with a sentence such as "Development: emails and messages are logged, not
116
150
  sent; payments use the sandbox." as its description. It has no label, so a
@@ -118,7 +152,9 @@ are refused there, as everywhere but production.
118
152
  - Local-password emails (confirmation and password reset) with an installed
119
153
  sender go out as the table says. In staging the sender gets
120
154
  `STAGING_EMAIL_TO` as `email` and the person's address as `originalEmail`,
121
- which its email should show (`markStagingEmail` does). An application that
155
+ which its email should show (`markStagingEmail` does); on a staging server
156
+ that real people use it gets the person's address and an empty
157
+ `originalEmail`, as in production. An application that
122
158
  confirms new accounts at once while its email isn't set up uses
123
159
  `auth.local.confirmation-mode`, which applies everywhere (see
124
160
  [Authentication](/guide/app-setup/authentication)).
@@ -145,7 +181,8 @@ project.
145
181
 
146
182
  Code the application writes that reaches the world follows the same rule. Send
147
183
  email and SMS through `deliverMessage`, which sends, redirects or logs each as
148
- `APP_ENV` says; log anything else outside production with `logSideEffect`.
184
+ `APP_ENV` (and, in staging, `STAGING_REACHES_REAL_PEOPLE`) says; log anything
185
+ else outside production with `logSideEffect`.
149
186
 
150
187
  ```js
151
188
  import { deliverMessage, logSideEffect, markStagingEmail } from "@jskit-ai/kernel/server/runtime/appEnvironment";
@@ -179,8 +216,11 @@ async function notifyDevice({ env, logger, push }, notification) {
179
216
 
180
217
  - Read `env` from the `runtime.env` capability, never a request.
181
218
  - A configured driver or key (`EMAIL_DRIVER=ses`, a live payment key) does not
182
- make anything real; only `APP_ENV=production` does.
219
+ make anything real; only `APP_ENV=production` does, and, for email and SMS
220
+ alone, `STAGING_REACHES_REAL_PEOPLE=true` on staging.
183
221
  - Test each environment the code treats differently. A test that proves a real
184
222
  sender against a fake transport passes `APP_ENV: "production"` (and
185
223
  `NODE_ENV: "production"` when it starts a whole server), and a staging test
186
- sets `STAGING_EMAIL_TO` and checks that only that address received it.
224
+ sets `STAGING_EMAIL_TO` and checks that only that address received it; one
225
+ for a staging server that real people use adds
226
+ `STAGING_REACHES_REAL_PEOPLE: "true"` and checks that the recipient did.
@@ -104,6 +104,9 @@ Exactly this, and nothing more:
104
104
  no parent. A literal destination is served by a page whose route matches it
105
105
  segment by segment, each `:param` standing for exactly one segment; the
106
106
  page's deeper pages (`modules/[moduleKey]/settings.vue`) are inner pages.
107
+ As the router does, a static page comes first: a link to `/jobs/new` leads
108
+ to `jobs/new.vue` when it exists, so `jobs/[jobId]/index.vue` stays an inner
109
+ page with its parent.
107
110
  3. **Every in-app link and navigation goes through JSKIT navigation:**
108
111
  `:to="paths.page('/suppliers')"` and `router.push(paths.page(...))` with
109
112
  `usePaths()`, the CRUD runtime's `resolveViewUrl()`, `resolveEditUrl()` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.341",
3
+ "version": "0.1.343",
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.28",
8
+ "@jskit-ai/kernel": "0.2.29",
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.28",
37
+ "@jskit-ai/kernel": "0.2.29",
38
38
  "@jskit-ai/material-web": "0.1.9",
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.28",
47
+ "@jskit-ai/http-runtime": "0.2.29",
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.93",
53
+ "@jskit-ai/jskit-catalog": "0.2.95",
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.28",
37
+ "@jskit-ai/kernel": "0.2.29",
38
38
  "@jskit-ai/material-web": "0.1.9",
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.28",
48
- "@jskit-ai/shell-web": "0.2.44",
47
+ "@jskit-ai/http-runtime": "0.2.29",
48
+ "@jskit-ai/shell-web": "0.2.45",
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.93",
54
+ "@jskit-ai/jskit-catalog": "0.2.95",
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.28"
12
+ "@jskit-ai/kernel": "0.2.29"
13
13
  },
14
14
  "jskit": {
15
15
  "kind": "runtime",
@@ -24,10 +24,14 @@ Exports
24
24
  - `APP_ENV_KEY`
25
25
  - `APP_ENVIRONMENTS`
26
26
  - `APP_ENVIRONMENT_META_NAME`
27
+ - `STAGING_REACHES_REAL_PEOPLE_KEY`
28
+ - `STAGING_REAL_PEOPLE_META_NAME`
27
29
  - `appEnvironment(env)`
28
30
  - `isStagingOrProduction(env)`
29
31
  - `pageAppEnvironment(documentObject = globalThis.document)`
30
- - `withAppEnvironmentMeta(html, environment)`
32
+ - `pageStagingReachesRealPeople(documentObject = globalThis.document)`
33
+ - `stagingReachesRealPeople(env)`
34
+ - `withAppEnvironmentMeta(html, environment, { reachesRealPeople = false } = {})`
31
35
 
32
36
  ### `support/clientBuild.js`
33
37
  Exports