@jskit-ai/agent-docs 0.1.58 → 0.1.60

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.
@@ -124,6 +124,79 @@ So the mental model is:
124
124
  - `realtime` gives the app a live transport
125
125
  - your own app code, or later packages, decide which events should travel across it
126
126
 
127
+ ## Publishing server events
128
+
129
+ Server code should publish realtime lifecycle events through JSKIT's entity-change helpers instead of hand-rolling `domainEvents.publish()` payloads.
130
+
131
+ Keep `operation` limited to resource invalidation semantics:
132
+
133
+ - `created`
134
+ - `updated`
135
+ - `deleted`
136
+
137
+ Use `action` for the domain lifecycle transition, and `reason` only when you need to explain why that transition happened.
138
+
139
+ For direct publishers, use `createRealtimeEntityChangePublisher()` from `@jskit-ai/kernel/server/runtime/entityChangeEvents`:
140
+
141
+ ```js
142
+ import { createRealtimeEntityChangePublisher } from "@jskit-ai/kernel/server/runtime/entityChangeEvents";
143
+
144
+ const publishProjectRuntimeChanged = createRealtimeEntityChangePublisher({
145
+ domainEvents,
146
+ source: "vibe64",
147
+ entity: "project",
148
+ event: "vibe64.project.changed",
149
+ serviceToken: "vibe64.terminals.service",
150
+ methodName: "projectRuntime"
151
+ });
152
+
153
+ await publishProjectRuntimeChanged("updated", projectSlug, {
154
+ action: "runtime-closed",
155
+ payload: {
156
+ message: "Project is closed.",
157
+ runtime: {
158
+ open: false
159
+ }
160
+ }
161
+ });
162
+ ```
163
+
164
+ The helper emits a normal `entity.changed` domain event with service metadata and `meta.realtime.event`. The realtime bridge uses that service metadata to find the registered socket dispatcher, then emits the socket event with canonical fields such as `source`, `entity`, `operation`, `entityId`, `scope`, and the lifecycle `action`.
165
+
166
+ For services registered through `app.service()`, declare the same semantics in service metadata:
167
+
168
+ ```js
169
+ app.service(
170
+ "vibe64.terminals.service",
171
+ (scope) => createTerminalsService({
172
+ repository: scope.make("vibe64.repository.terminals")
173
+ }),
174
+ {
175
+ events: {
176
+ projectRuntime: [
177
+ {
178
+ type: "entity.changed",
179
+ source: "vibe64",
180
+ entity: "project",
181
+ operation: "updated",
182
+ entityId: ({ args }) => args?.[0]?.projectSlug,
183
+ action: "runtime-closed",
184
+ realtime: {
185
+ event: "vibe64.project.changed",
186
+ payload: ({ result }) => ({
187
+ message: result?.message || "",
188
+ runtime: result?.runtime || null
189
+ })
190
+ }
191
+ }
192
+ ]
193
+ }
194
+ }
195
+ );
196
+ ```
197
+
198
+ `action`, `reason`, and `realtime.payload` may be functions when the value depends on the service result or arguments. Do not encode lifecycle names by widening `operation`; keep `operation` truthful for CRUD/resource contracts and put domain-specific lifecycle meaning in metadata.
199
+
127
200
  ## What `realtime` adds to the app
128
201
 
129
202
  This chapter is small enough that it is worth looking directly at the app-owned files it changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.58",
3
+ "version": "0.1.60",
4
4
  "description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
5
5
  "type": "module",
6
6
  "files": [
@@ -36,6 +36,7 @@ Local functions
36
36
  Exports
37
37
  - `safeRequestCookies(request)`
38
38
  - `cookieOptions(isProduction, maxAge)`
39
+ - `cookieClearOptions(isProduction)`
39
40
 
40
41
  ### `src/server/lib/authenticatedProfile.js`
41
42
  Exports
@@ -678,7 +678,7 @@ Exports
678
678
  Exports
679
679
  - `normalizeDescriptorUiRoutes(value)`
680
680
  - `normalizeDescriptorClientProviders(value)`
681
- - `normalizeDescriptorClientOptimizeIncludeSpecifiers(value)`
681
+ - `normalizeDescriptorClientOptimizeSpecifiers(value)`
682
682
  - `normalizeClientDescriptorSections(descriptorValue)`
683
683
 
684
684
  ### `client/index.js`
@@ -782,7 +782,7 @@ Exports
782
782
  - `CLIENT_BOOTSTRAP_VIRTUAL_ID`
783
783
  - `CLIENT_BOOTSTRAP_RESOLVED_ID`
784
784
  - `createVirtualModuleSource(clientModules = [])`
785
- - `resolveClientOptimizeIncludeSpecifiers(clientModules = [])`
785
+ - `resolveClientOptimizeIncludeSpecifiers(clientModules = [], excludeSpecifiers = [])`
786
786
  - `resolveClientOptimizeExcludeSpecifiers(clientModules = [])`
787
787
  - `resolveLocalScopeOptimizeExcludeSpecifiers(localScopePackageIds = [])`
788
788
  - `resolveInstalledClientPackageIds(options)`
@@ -1163,6 +1163,7 @@ Local functions
1163
1163
  - `normalizeServiceEventType(value, { context = "service event" } = {})`
1164
1164
  - `normalizeServiceEventOperation(value, { context = "service event" } = {})`
1165
1165
  - `normalizeServiceEventEntityId(value)`
1166
+ - `normalizeServiceEventMetaField(value, { context = "service event meta field" } = {})`
1166
1167
  - `normalizeRealtimeDispatch(value, { context = "service event.realtime" } = {})`
1167
1168
  - `normalizeRealtimeAudience(value, { context = "service event.realtime.audience" } = {})`
1168
1169
  - `normalizeServiceEventSpec(entry, { context = "service event" } = {})`
@@ -1171,6 +1172,7 @@ Local functions
1171
1172
  - `resolveMethodOptions(args = [])`
1172
1173
  - `resolveEventOperation(spec, state)`
1173
1174
  - `resolveEventEntityId(spec, state)`
1175
+ - `resolveEventMetaField(value, state)`
1174
1176
  - `resolveEventMeta(spec, state)`
1175
1177
  - `createServiceMethodEventPublisher(scope, serviceToken, methodName, specs = [])`
1176
1178
 
@@ -1217,12 +1219,17 @@ Exports
1217
1219
  Exports
1218
1220
  - `resolveDefaultScope(visibilityContext = {}, runtime = {})`
1219
1221
  - `createEntityChangePublisher({ domainEvents, source, entity, scopeResolver = resolveDefaultScope } = {})`
1222
+ - `createRealtimeEntityChangePublisher({ domainEvents, source, entity, event, serviceToken, methodName, scopeResolver = resolveDefaultScope } = {})`
1220
1223
  - `createNoopEntityChangePublisher()`
1221
1224
  Local functions
1222
1225
  - `resolveContextScope(context = {})`
1223
1226
  - `resolveVisibilityScope(visibilityContext = {}, runtimeContext = {})`
1224
1227
  - `resolveCommandId(requestMeta = {})`
1225
1228
  - `resolveSourceClientId(requestMeta = {})`
1229
+ - `normalizeMetaTextField(source = {}, fieldName = "", { context = "realtime entity change" } = {})`
1230
+ - `normalizeRealtimePayload(value, { context = "realtime entity change.payload" } = {})`
1231
+ - `createRealtimeEntityChangeMeta({ serviceToken, methodName, event, change = {} } = {})`
1232
+ - `resolveRealtimeEntityChangeOptions(change = {}, options = {})`
1226
1233
 
1227
1234
  ### `server/runtime/errors.js`
1228
1235
  Exports
@@ -198,6 +198,26 @@ Local functions
198
198
  Exports
199
199
  - `resolveActionUser(context, input)`
200
200
 
201
+ ### `src/server/previewUserProvisioning.js`
202
+ Exports
203
+ - `DEFAULT_AUTH_PROVIDER`
204
+ - `DEFAULT_DISPLAY_NAME`
205
+ - `DEFAULT_EMAIL`
206
+ - `ensurePreviewUser(db, profileInput = {})`
207
+ - `normalizePreviewUserProfile(profile = {})`
208
+ - `profileFromUserRow(user = {}, fallback = {})`
209
+ Local functions
210
+ - `normalizeText(value = "")`
211
+ - `normalizeLowerText(value = "")`
212
+ - `normalizeUsername(value = "")`
213
+ - `usernameBaseFromEmail(email = "")`
214
+ - `buildUsernameCandidate(baseUsername = "", suffix = 0)`
215
+ - `isDuplicateError(error)`
216
+ - `resolveUniqueUsername(db, baseUsername = "", { excludeUserId = "" } = {})`
217
+ - `findPreviewUser(db, profile = {})`
218
+ - `ensurePreviewUserRow(db, profile = {})`
219
+ - `ensureUserSettings(db, user = {})`
220
+
201
221
  ### `src/server/profileSyncLifecycleContributorRegistry.js`
202
222
  Exports
203
223
  - `PROFILE_SYNC_LIFECYCLE_CONTRIBUTOR_TAG`
@@ -114,6 +114,25 @@ Exports
114
114
  - `routeParamsValidator`
115
115
  - `workspaceSlugParamsValidator`
116
116
 
117
+ ### `src/server/previewWorkspaceProvisioning.js`
118
+ Exports
119
+ - `buildWorkspaceBaseSlug(profile = {})`
120
+ - `buildWorkspaceName(profile = {})`
121
+ - `ensurePreviewWorkspace(db, user = {}, profile = {}, { appConfig = {}, tenancyMode = "" } = {})`
122
+ - `normalizeWorkspaceResult(workspace = null)`
123
+ Local functions
124
+ - `normalizeText(value = "")`
125
+ - `normalizeLowerText(value = "")`
126
+ - `workspaceSlugPart(value = "")`
127
+ - `usernameBaseFromEmail(email = "")`
128
+ - `buildWorkspaceSlugCandidate(baseSlug = "", suffix = 0)`
129
+ - `isDuplicateError(error)`
130
+ - `resolveUniqueWorkspaceSlug(db, baseSlug = "", { excludeWorkspaceId = "" } = {})`
131
+ - `hasWorkspaceTables(db)`
132
+ - `findPreviewWorkspace(db, user = {}, { isPersonal = true } = {})`
133
+ - `ensureWorkspaceSettings(db, workspace = {})`
134
+ - `ensureOwnerMembership(db, workspace = {}, user = {})`
135
+
117
136
  ### `src/server/registerWorkspaceBootstrap.js`
118
137
  Exports
119
138
  - `registerWorkspaceBootstrap(app)`
@@ -400,6 +400,23 @@ Local functions
400
400
  - `replaceWithSymlink(targetPath = "", sourceDir = "", { packageName = "" } = {})`
401
401
  - `maybeLinkCompanionPackages({ appRoot = "", repoRoot = "", stdout, createCliError })`
402
402
 
403
+ ### `src/server/commandHandlers/appCommands/preparePreviewUser.js`
404
+ Exports
405
+ - `runAppPreparePreviewUserCommand(_ctx = {}, { appRoot = "", options = {}, stdout = process.stdout })`
406
+ Local functions
407
+ - `normalizeText(value = "")`
408
+ - `normalizeLowerText(value = "")`
409
+ - `profileFromOptions(options = {})`
410
+ - `fileExists(filePath = "")`
411
+ - `createAppRequire(appRoot = "")`
412
+ - `importFreshModule(filePath = "")`
413
+ - `loadKnexConfig(appRoot = "")`
414
+ - `importAppPackageExport(appRoot = "", specifier = "", { required = true } = {})`
415
+ - `writeProfile(profileFile = "", authProfile = {})`
416
+ - `isTrueOption(value)`
417
+ - `normalizeTenancyMode(value = "")`
418
+ - `hasWorkspaceTables(db)`
419
+
403
420
  ### `src/server/commandHandlers/appCommands/release.js`
404
421
  Exports
405
422
  - `runAppReleaseCommand(ctx = {}, { appRoot = "", options = {}, stdout, stderr })`