@jskit-ai/agent-docs 0.1.193 → 0.1.195

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 (40) hide show
  1. package/guide/agent/app-extras/assistant-conversation.md +2608 -72
  2. package/guide/agent/app-extras/assistant-voice.md +244 -0
  3. package/guide/agent/app-extras/assistant.md +189 -20
  4. package/guide/agent/app-extras/realtime.md +6 -0
  5. package/guide/agent/app-setup/database-layer.md +74 -5
  6. package/guide/agent/app-setup/existing-application-migration.md +34 -29
  7. package/guide/agent/app-setup/multi-homing.md +93 -116
  8. package/guide/agent/framework/crud-operations.md +16 -2
  9. package/guide/agent/index.md +1 -0
  10. package/package.json +1 -1
  11. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  12. package/patterns/minimal-foundation/example/package.json +4 -4
  13. package/patterns/shell-foundation/example/package.json +5 -5
  14. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  15. package/reference/autogen/PATTERN_INDEX.md +35 -35
  16. package/reference/autogen/README.md +2 -0
  17. package/reference/autogen/packages/assistant-core.md +974 -9
  18. package/reference/autogen/packages/assistant-runtime.md +126 -28
  19. package/reference/autogen/packages/assistant-voice-sherpa.md +82 -0
  20. package/reference/autogen/packages/assistant-voice.md +227 -0
  21. package/reference/autogen/packages/kernel.md +10 -0
  22. package/reference/autogen/packages/realtime.md +5 -2
  23. package/skills/jskit/SKILL.md +1 -1
  24. package/skills/jskit/references/crud-operations.md +16 -2
  25. package/skills/jskit/references/existing-application-migration.md +34 -29
  26. package/skills/jskit/references/multi-homing.md +93 -116
  27. package/skills/jskit/references/pattern-index.md +35 -35
  28. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +4 -4
  29. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +5 -5
  30. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  31. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  32. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +4 -4
  33. package/skills/jskit/references/patterns/crud/json-api-resource-package/example/packages/books/package.json +2 -2
  34. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +1 -1
  35. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +1 -1
  36. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  37. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  38. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +2 -2
  39. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +3 -3
  40. package/skills/jskit/references/patterns/workspaces/workspace-server/PATTERN.md +23 -28
@@ -219,33 +219,28 @@ or unresolved write.
219
219
 
220
220
  ### Workspace invitation transaction compatibility (workspaces-core 0.1.198)
221
221
 
222
- Workspace invitation creation, acceptance and refusal now own managed
223
- transactions. Existing calls to `members.createInvite(..., { trx })` must become
224
- `members.prepareInvite(..., { trx })`, application association/receipt writes,
225
- confirmed commit, then `members.sendInvite(...)` without `trx`. Move writes that
226
- must accompany built-in acceptance into
227
- `pendingInvitations.registerAcceptanceParticipant(fn)` during feature setup.
228
- Acceptance/refusal reject borrowed transactions; revocation can still participate
229
- in a managed transaction. Ordinary invitation actions retain their IDs and
230
- response shapes. Terminal repository transitions now reject instead of
231
- rewriting already accepted/revoked invitations. Mailer exceptions return a fixed
232
- message to avoid leaking invitation tokens from provider diagnostics.
233
-
234
- Required participant writes roll back together. Preserve transaction outcomes:
235
- a failure after commit is not rollback, and an unresolved commit must not be
236
- blindly replayed. Matching-recipient expiry revocation deliberately commits
237
- before its 409 rejection. Review the
238
- [workspace invitation contract and example](./multi-homing.md#transactional-invitation-participation)
239
- when migrating. No schema migration is required for these framework APIs.
240
-
241
- The first coordinated release containing this contract includes
222
+ Invitation creation, acceptance and refusal now own their managed transactions:
223
+
224
+ - Replace `members.createInvite(..., { trx })` with
225
+ `members.prepareInvite(..., { trx })`, save the application association/receipt,
226
+ commit, then call `members.sendInvite(...)` without `trx`.
227
+ - Move related acceptance writes into
228
+ `pendingInvitations.registerAcceptanceParticipant(fn)` during feature setup.
229
+ Acceptance/refusal reject borrowed transactions; revocation can still join one.
230
+ - Terminal repository transitions reject accepted/revoked invitations. Mailer
231
+ exceptions return a fixed message to keep tokens out of provider diagnostics.
232
+
233
+ Participant writes roll back together. Preserve transaction outcomes when handling
234
+ errors: completion-hook failures cannot undo a commit, and expiry revocation
235
+ commits before returning 409. See the
236
+ [workspace invitation contract and example](./multi-homing.md#transactional-invitation-participation).
237
+ Action IDs, response shapes and schema are unchanged.
238
+
239
+ The first coordinated release includes
242
240
  `@jskit-ai/workspaces-core@0.1.198`, `@jskit-ai/jskit-catalog@0.1.245` and
243
- `@jskit-ai/agent-docs@0.1.192`. Once that release is published, use
244
- `npm run jskit:update` in the application to upgrade the coordinated graph,
245
- restart the backend, check the actual installed versions, and assert
246
- that `prepareInvite`, `sendInvite` and `registerAcceptanceParticipant` are present
247
- on the resolved capability. Application domain integration and real email
248
- activation remain separate work.
241
+ `@jskit-ai/agent-docs@0.1.192`. Run `npm run jskit:update`, restart the backend,
242
+ and check the installed versions and methods on `workspaces.core`. Application
243
+ integration and real email activation remain separate work.
249
244
 
250
245
  ## 4. Adopt migrations without breaking either database history
251
246
 
@@ -256,9 +251,15 @@ historical migration when moving it so the existing Knex ledger continues to
256
251
  recognize it. Basenames must be unique across the effective graph.
257
252
 
258
253
  Keep cross-package foreign keys and other dependency-sensitive constraints in
259
- later application-owned migrations when package ordering requires it. Seeds
260
- are not migrations: run one explicit application-owned, idempotent seed after
261
- the complete graph has migrated.
254
+ application `migrations/constraints/`, the final phase of
255
+ `createKnexMigrationConfigFromApp()`. It uses `sortDirsSeparately: true`: root
256
+ `migrations/` runs before the sorted package directories, and filenames only
257
+ order work within their own directory. A later timestamp in a package does not
258
+ defer its foreign key until another package has created the parent table.
259
+ Follow the [database ordering and partial-failure recovery rules](https://mobily-enterprises.github.io/jskit-ai/guide/app-setup/database-layer#directory-order-comes-before-filenames),
260
+ including independent checks for columns and constraints after MySQL or MariaDB
261
+ DDL fails. Seeds are not migrations: run one explicit application-owned,
262
+ idempotent seed after the complete graph has migrated.
262
263
 
263
264
  Prove both histories:
264
265
 
@@ -269,6 +270,10 @@ Prove both histories:
269
270
  with the intended schema.
270
271
  3. Run the normal migrate-then-seed entry point twice. The second run must have
271
272
  no pending migration and the seed must be safe and stable.
273
+ 4. In disposable fixtures, prove upgrade from the previous schema preserves
274
+ rows, and multi-step MySQL or MariaDB DDL resumes from partial completion
275
+ with the intended foreign keys enforced. Read-only ledger inspection alone
276
+ does not prove an upgrade or recovery.
272
277
 
273
278
  A managed editor allocates one isolated mutable development database per
274
279
  session. It owns creation, credentials, lifetime, and environment injection;
@@ -41,23 +41,20 @@ a policy/runtime mismatch.
41
41
 
42
42
  ## Transactional invitation participation
43
43
 
44
- Use the existing `workspaces.core` capability when accepting an invitation must
45
- also connect an application-owned identity, training history, access scopes or
46
- required audit records. JSKIT owns tokens, invitation state and membership; the
47
- application owns its reviewed association and domain policy. The built-in
48
- `workspace.invite.redeem` action runs the participant. No replacement route,
49
- client follow-up save or after-action event is needed.
44
+ Use `workspaces.core` to connect application records during the built-in
45
+ `workspace.invite.redeem` action. JSKIT owns tokens, invitation state and
46
+ membership. The application owns its reviewed person association, training,
47
+ access scopes and audit records.
50
48
 
51
- Saving intended access without sending remains an application draft. Do not call
52
- preparation until an administrator deliberately issues an invitation: preparation
53
- creates a real token and pending invitation, but does not activate membership.
49
+ Keep intended access in an application draft until an administrator issues an
50
+ invitation. Preparation creates a token and pending invitation without activating
51
+ membership or sending mail.
54
52
 
55
53
  ### Public server methods
56
54
 
57
- These methods are trusted server composition APIs, not new public actions. The
58
- caller must authorize creation, delivery and revocation in the requested workspace.
59
- The ordinary invitation routes retain their existing authorization and role
60
- validation. Do not forward arbitrary HTTP input as server composition options.
55
+ These server APIs require the caller to authorize creation, delivery and
56
+ revocation in the requested workspace. Ordinary invitation routes retain their
57
+ authorization and role checks. Do not pass arbitrary HTTP input as options.
61
58
 
62
59
  | Capability method | Contract |
63
60
  | --- | --- |
@@ -70,20 +67,18 @@ validation. Do not forward arbitrary HTTP input as server composition options.
70
67
 
71
68
  `sendInvite` accepts `{ createdInviteId, inviteTokenPreview }` from preparation or
72
69
  only `{ createdInviteId }` for a later attempt. The latter uses JSKIT's existing
73
- opaque token-hash encoding without rotating the token. Supplying an empty or
74
- mismatched token rejects. Email, role, expiry and workspace display fields come
75
- from the stored invitation/workspace, not replacement input. Its response keeps
70
+ opaque token-hash encoding without rotating the token. Empty or mismatched tokens
71
+ reject. Email, role, expiry and workspace display fields come from stored records.
72
+ The response includes
76
73
  `createdInviteId`, `inviteTokenPreview`, `inviteUrl` and `inviteDelivery` alongside
77
- the ordinary workspace/invitation-list payload. Treat tokens and URLs as secrets;
78
- do not log them or put them in diagnostic messages or administrative receipts.
79
- A receipt normally needs only the exact invitation ID.
74
+ the ordinary workspace/invitation-list payload. Keep tokens and URLs out of logs,
75
+ diagnostics and administrative receipts; save the invitation ID in the receipt.
80
76
 
81
77
  ### Preparation, association, commit and controlled delivery
82
78
 
83
- Inside application feature setup, declare `workspaces: "workspaces.core"` in
84
- `requires`, then use that capability. The `reviewedPeople`, `people`, `scopes`
85
- and `audit` names below represent application-owned services, not JSKIT APIs.
86
- Their writes must forward the provided transaction to their repositories.
79
+ Declare `workspaces: "workspaces.core"` in the application's feature `requires`.
80
+ In this example, `reviewedPeople`, `people`, `scopes` and `audit` are application
81
+ services. Each forwards the supplied transaction to its repositories.
87
82
 
88
83
  ```js
89
84
  // During application Feature.setup, before serving requests:
@@ -118,25 +113,22 @@ const prepared = await invites.withTransaction(async (trx) => {
118
113
  }, options);
119
114
  await reviewedPeople.associateInvitationAndSaveReceipt(reviewed, requestId, created.createdInviteId, options);
120
115
  return { createdInviteId: created.createdInviteId };
121
- }); // Confirmed commit; a rejection here must not fall through to delivery.
116
+ });
122
117
 
123
118
  const result = await members.sendInvite(workspace, actor, prepared, { context });
124
- // Persist delivery feedback through the application owner. Avoid logging result:
125
- // it contains a secret token and URL as well as the nonsecret delivery outcome.
119
+ // Store the delivery outcome, not the token or URL in result.
126
120
  await reviewedPeople.recordDeliveryOutcome(prepared.createdInviteId, result.inviteDelivery, { context });
127
121
  ```
128
122
 
129
- The application must lock its reviewed draft/receipt, enforce request identity,
130
- and reject changed input on a reused request ID. A retry after losing the
131
- preparation response reads that receipt instead of preparing another invitation.
132
- Association failure rolls back the new invitation, replacement of an older
133
- invitation, receipt and application writes. This is not generic framework
134
- idempotency, and does not imply exactly-once email.
123
+ Lock the reviewed draft/receipt and reject changed input on a reused request ID.
124
+ After a lost preparation response, read the receipt instead of preparing another
125
+ invitation. Association failure rolls back the new invitation, replacement of
126
+ the previous invitation, receipt and application writes. Send only after the
127
+ transaction resolves successfully.
135
128
 
136
- Real SMTP is unnecessary for implementation and verification. With no
137
- `workspaceInviteMailer`, delivery returns `status: "mailer_unconfigured"`, an
138
- explanatory `message` and an empty `providerMessageId`; the invitation remains
139
- committed. A test application can configure a controlled mailer:
129
+ With no `workspaceInviteMailer`, delivery returns `status: "mailer_unconfigured"`,
130
+ an explanatory `message` and an empty `providerMessageId`; the invitation remains
131
+ committed. Use a controlled mailer in tests; SMTP is unnecessary:
140
132
 
141
133
  ```js
142
134
  workspaceInviteMailer: {
@@ -147,86 +139,75 @@ workspaceInviteMailer: {
147
139
  }
148
140
  ```
149
141
 
150
- A thrown renderer/mailer error returns `inviteDelivery.status: "failed"` and a
151
- fixed message, avoiding accidental token leakage through provider exceptions.
152
- It does not delete the invitation/association or activate membership. Mailer
153
- results retain their normalized status, message and provider message ID; a
154
- successful default is `sent`. A provider exception or interrupted response may
155
- occur after a provider accepted the message: `failed` is not proof of nondelivery.
156
- There is no exactly-once delivery guarantee. Applications own durable delivery
157
- attempts and safe retry policy. Validation checks committed invitation state
158
- before sending; revocation after sending starts cannot recall the message.
142
+ Renderer/mailer exceptions return `inviteDelivery.status: "failed"` with a fixed
143
+ message to keep provider errors from exposing tokens. Persistence is unchanged.
144
+ Successful mailer results retain their normalized status, message and provider
145
+ message ID; the default status is `sent`.
146
+
147
+ A provider may accept a message before throwing or losing its response. The
148
+ application must track delivery attempts and decide when to retry; email is not
149
+ exactly once. Revocation after sending starts cannot recall a message.
159
150
 
160
151
  ### Acceptance and failure semantics
161
152
 
162
- Register one callback during feature setup. It composes any application domain
163
- owners explicitly. Non-functions throw `TypeError`; a second registration
164
- throws, and registration closes when acceptance/refusal first begins. The
165
- callback's invite, user and options envelope are shallow frozen. It receives the
166
- same managed `trx` and request `context`; transaction ownership stays with JSKIT.
167
-
168
- Acceptance authenticates the user, checks email, pending state and expiry, then
169
- revalidates the invitation under workspace/invitation locks. Membership is
170
- available as active inside that transaction before the callback runs. Existing
171
- role-upsert semantics remain: the stored invitation role becomes the membership
172
- role, including for an existing membership. The callback cannot authorize role
173
- or scope overrides from client input. It must recheck the reviewed version,
174
- workspace, current inviter authority, person eligibility, existing account link,
175
- and scope eligibility using application-owned data.
176
-
177
- An ordinary invitation with no application association may pass through. A
178
- stale, revoked, conflicting or expected-but-missing association must fail closed.
179
- The application needs enough durable association/review state to distinguish
180
- these cases; absence alone cannot identify a deleted reviewed association.
181
-
182
- Await every owner write and forward the same transaction. Do not commit,
183
- roll back, use savepoints, start a new transaction, or perform external side
184
- effects in the callback. Do not swallow failures. Participant exceptions and
185
- later invitation-status failures roll back membership (including its prior role
186
- and status), person/training links, scopes, required audit and accepted status.
187
- The callback is not invoked for an invalid invitation or on refusal. Acceptance
188
- and refusal reject borrowed `options.trx`; revocation can join a managed
189
- transaction or own one when none is supplied.
190
-
191
- A missing/already-handled invitation rejects with 404; mismatched authenticated
192
- email with 403; unauthenticated access with 401. An expired invitation for its
193
- matching recipient is revoked in a committed transaction and then rejects with
194
- 409 and `transactionOutcome: "committed"`. It never activates membership or
195
- runs the participant. A failure to commit that revocation preserves the managed
196
- transaction error instead. Delivery rejects missing/foreign/handled invitations
197
- with 404, expired invitations with 409, and mismatched tokens with 400.
198
-
199
- Keep `error.transactionOutcome` and `error.cause` when translating failures.
200
- `rolledBack` confirms rollback; `committed` can indicate a completion-hook error
201
- after successful persistence; `unknown` leaves the outcome unresolved. A thrown
202
- error alone does not prove rollback. After-commit failures and external effects
203
- cannot be included in the atomic guarantee. See
153
+ Register one callback during feature setup to call the required application
154
+ services. Non-functions throw `TypeError`; duplicate registration throws, and
155
+ registration closes when acceptance/refusal first begins. The callback's invite,
156
+ user and options are shallow frozen. JSKIT owns the transaction and passes its
157
+ `trx` and request `context` to the callback.
158
+
159
+ Acceptance checks authentication, recipient email, pending state and expiry under
160
+ workspace/invitation locks. Before calling the participant, it activates membership
161
+ with the stored invitation role, including when updating an existing membership.
162
+ The participant must use application data to check the review version, workspace,
163
+ current inviter authority, person eligibility, existing account link and scope
164
+ eligibility. Client input cannot authorize role or scope overrides.
165
+
166
+ An ordinary invitation without an application association may pass through.
167
+ Reject stale, revoked, conflicting or unexpectedly missing associations. Retain
168
+ enough review history to distinguish ordinary invitations from deleted associations.
169
+
170
+ Await every write with the same transaction and let failures propagate. The
171
+ callback must not commit, roll back, create transactions/savepoints or perform
172
+ external effects. Participant and later invitation-status failures roll back
173
+ membership (including its previous role/status), person/training links, scopes,
174
+ audit and accepted status. Invalid invitations and refusals do not call the
175
+ participant. Acceptance/refusal reject borrowed `options.trx`; revocation can
176
+ join a managed transaction or create one.
177
+
178
+ Acceptance/refusal return 401 for unauthenticated access, 403 for a recipient
179
+ email mismatch and 404 for a missing or handled invitation. A matching recipient's
180
+ expired invitation is revoked and committed before returning 409 with
181
+ `transactionOutcome: "committed"`, without activating membership or calling the
182
+ participant. A failed revocation commit retains its transaction error. Delivery
183
+ returns 404 for missing, foreign or handled invitations, 409 for expiry and 400
184
+ for a token mismatch.
185
+
186
+ Preserve `error.transactionOutcome` and `error.cause`: `rolledBack` confirms
187
+ rollback, `committed` can accompany a failed completion hook, and `unknown`
188
+ requires resolving the outcome before retrying. Errors after commit cannot undo
189
+ persistence. See
204
190
  [managed transaction guidance](./existing-application-migration.md#json-rest-v2-integration).
205
191
 
206
- Invitation mutations lock workspace before invitation rows, and use current
207
- locking reads before terminal transitions. Accepted/revoked state cannot be
208
- overwritten by a losing acceptance, refusal, revocation or replacement. A
209
- replacement after acceptance may create a new pending invitation while retaining
210
- the older accepted invitation. Keep callbacks short: invitation changes in the
211
- same workspace serialize. Database deadlocks/serialization failures remain
212
- transaction errors; callbacks are not automatically replayed.
192
+ Invitation mutations lock workspace before invitation rows. A losing acceptance,
193
+ refusal, revocation or replacement cannot overwrite accepted/revoked state.
194
+ Replacement can create a new pending invitation after acceptance while retaining
195
+ the accepted invitation. Keep callbacks short: invitation changes in one workspace
196
+ serialize. Deadlocks/serialization failures propagate without replaying callbacks.
213
197
 
214
198
  ### Compatibility and verification
215
199
 
216
- This server-composition contract starts with `@jskit-ai/workspaces-core@0.1.198`.
217
- Transactional callers of
218
- `createInvite` must migrate to preparation plus post-commit delivery. Related
219
- acceptance writes must move into the participant. `markAcceptedById` and
220
- `revokeById` now reject terminal/missing invitations rather than overwriting their
221
- state. No route/action ID, package export, table or migration is added.
222
-
223
- Verify ordinary invitations, rollback after each domain write, late framework
224
- failure, existing membership restoration, recipient checks, stale associations,
225
- controlled delivery failures and lost-response receipts. Run the normal redeem
226
- action in tests. Use independent connections to race acceptance against acceptance,
227
- refusal, revocation and replacement in both winning orders. The package fixture
228
- runs these races on native MySQL/MariaDB and PostgreSQL; SQLite skips those races
229
- and is not evidence of native locking correctness.
200
+ Since `@jskit-ai/workspaces-core@0.1.198`, transactional `createInvite` callers
201
+ must use preparation followed by delivery after commit. Move related acceptance
202
+ writes into the participant. `markAcceptedById` and `revokeById` reject missing
203
+ or handled invitations. Route/action IDs, package exports and schema are unchanged.
204
+
205
+ Test through the normal redeem action: ordinary invitations, rollback after
206
+ application and final status writes, existing membership restoration, invalid
207
+ recipients/associations, controlled delivery failures and lost-response receipts.
208
+ The package fixture tests competing acceptance, refusal, revocation and replacement
209
+ in both winning orders on independent MySQL/MariaDB and PostgreSQL connections.
210
+ SQLite skips those races.
230
211
 
231
212
  Use only a verified empty disposable database named
232
213
  `jskit_repository_test_*` for native tests. The runner verifies the actual target,
@@ -239,17 +220,13 @@ node --test packages/workspaces-core/test/repositories.integration.test.js
239
220
  npm run verify
240
221
  ```
241
222
 
242
- A passing framework fixture does not complete the application's People, training,
243
- permissions, privacy or browser integration. Publication remains a separate
244
- maintainer operation. After a coordinated release is published, run the
245
- application's `npm run jskit:update`, restart its backend and verify that
223
+ Run the application's `npm run jskit:update`, restart its backend and verify that
246
224
  `members.prepareInvite`, `members.sendInvite` and
247
225
  `pendingInvitations.registerAcceptanceParticipant` are functions on the installed
248
- `workspaces.core` capability. Check the installed package/catalogue versions
249
- against that release. The first coordinated release containing this contract pairs
226
+ `workspaces.core` capability. The first release containing this contract pairs
250
227
  `@jskit-ai/workspaces-core@0.1.198`, `@jskit-ai/jskit-catalog@0.1.245` and
251
- `@jskit-ai/agent-docs@0.1.192`. Upgrade the coordinated dependency graph rather
252
- than pinning only `workspaces-core`. Do not patch installed `node_modules`.
228
+ `@jskit-ai/agent-docs@0.1.192`. Upgrade the coordinated dependency graph, then run
229
+ the application's identity, training, permission, privacy and browser tests.
253
230
 
254
231
  ## Browser composition
255
232