@keemakr/ui-sdk 1.5.0-dev-20261022115136 → 1.5.0-dev-20261022120138

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.
package/dist/filters.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Press } from './schema.js';
1
+ import type { ValuePress } from './schema.js';
2
2
  /**
3
3
  * How long a search box waits after the last keystroke before it fires. The
4
4
  * renderer decides this, not the module, so every app feels the same.
@@ -24,7 +24,7 @@ export declare function toggleValue(values: readonly string[], value: string, op
24
24
  * in under `name` — comma-joined into `params` for a navigate ('' when none is
25
25
  * on), an array of strings into `input` for an action.
26
26
  */
27
- export declare function pressWithValues(press: Press, name: string, values: readonly string[]): Press;
27
+ export declare function pressWithValues(press: ValuePress, name: string, values: readonly string[]): ValuePress;
28
28
  /** What a renderer needs of a form to treat it as a live search box. */
29
29
  export interface LiveSearchFormLike {
30
30
  fields: ReadonlyArray<{
@@ -33,7 +33,7 @@ export interface LiveSearchFormLike {
33
33
  label: string;
34
34
  value?: string;
35
35
  }>;
36
- onChange?: Press;
36
+ onChange?: ValuePress;
37
37
  }
38
38
  /**
39
39
  * The one text field of a live search form, or undefined when the form is not
@@ -51,4 +51,4 @@ export type SearchTrigger = 'pause' | 'enter' | 'clear';
51
51
  */
52
52
  export declare function searchFires(text: string, sent: string, trigger: SearchTrigger): boolean;
53
53
  /** The press a live search form fires for `text`: trimmed, under the field's name. */
54
- export declare function searchPress(form: LiveSearchFormLike, text: string): Press | undefined;
54
+ export declare function searchPress(form: LiveSearchFormLike, text: string): ValuePress | undefined;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { UI_SCHEMA_VERSION, pressSchema, buttonSchema, cellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, } from './schema.js';
2
- export type { Press, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree, ActionResult, InterfaceFamily, SurfaceDefinition, Surface, ScreenRegistration, UiManifest, ScreenTreeInput, ActionResultInput, JobStatus, JobStatusInput, } from './schema.js';
1
+ export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, buttonSchema, cellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, } from './schema.js';
2
+ export type { Press, ChatPress, ValuePress, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree, ActionResult, InterfaceFamily, SurfaceDefinition, Surface, ScreenRegistration, UiManifest, ScreenTreeInput, ActionResultInput, JobStatus, JobStatusInput, } from './schema.js';
3
3
  export { CHART_POINTS_MAX, thinChart, thinnedIndices } from './chart.js';
4
4
  export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
5
5
  export type { ContainerChild, ContainerNodeType, KnownNodeType } from './nodes.js';
6
6
  export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
7
7
  export { SEARCH_DEBOUNCE_MS, SEARCH_MIN_LENGTH, liveSearchField, pressWithValues, searchFires, searchPress, splitValues, toggleValue, } from './filters.js';
8
8
  export type { LiveSearchFormLike, SearchTrigger } from './filters.js';
9
- export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
9
+ export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, isChatPress, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
10
10
  export type { ClientRelease, ClientTarget, Fallback, NegotiatedTree, NodeSet, UiFeature, UiSdkSnapshot, } from './negotiate.js';
11
11
  export { PUBLISHED_PARSERS, type PublishedParser } from './published/index.js';
12
12
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@
6
6
  // platform components, proxies load/action with a grant
7
7
  //
8
8
  // Module code never ships to the browser. UI is data, not code.
9
- export { UI_SCHEMA_VERSION, pressSchema, buttonSchema, cellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, } from './schema.js';
9
+ export { UI_SCHEMA_VERSION, pressSchema, chatPressSchema, valuePressSchema, buttonSchema, cellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, } from './schema.js';
10
10
  export { CHART_POINTS_MAX, thinChart, thinnedIndices } from './chart.js';
11
11
  export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
12
12
  export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
13
13
  export { SEARCH_DEBOUNCE_MS, SEARCH_MIN_LENGTH, liveSearchField, pressWithValues, searchFires, searchPress, splitValues, toggleValue, } from './filters.js';
14
- export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
14
+ export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, isChatPress, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
15
15
  export { PUBLISHED_PARSERS } from './published/index.js';
16
16
  export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
17
17
  export { formPress, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, } from './form.js';
@@ -1,4 +1,4 @@
1
- import type { ScreenRootNode, ScreenTree } from './schema.js';
1
+ import type { ChatPress, ScreenRootNode, ScreenTree } from './schema.js';
2
2
  /**
3
3
  * Tree features below the node level that a client may or may not draw.
4
4
  *
@@ -11,12 +11,17 @@ import type { ScreenRootNode, ScreenTree } from './schema.js';
11
11
  * - `form.confirm`: the client asks `submit.confirm` (and a `secondary` send's `confirm`) before
12
12
  * the form posts. Without it, a form that carries one becomes one calm line, so nothing posts
13
13
  * without asking.
14
+ * - `press.chat`: a `chat` press opens the client's chat with the prompt typed in, never sent.
15
+ * Without it, nothing offers to open the chat: a body button with one becomes its label as
16
+ * muted text, a header, row, calendar entry or alert button with one is dropped, and a row,
17
+ * card, entry or image keeps its place but is no longer pressable. A choice with one is
18
+ * dropped, and choices with nothing left become one line of their titles.
14
19
  * - `form.radio`: the `radio` field kind and an option's `badge` and `description` (newer than
15
20
  * any published release; core's own renderer draws them). Without it, a radio is a `select`
16
21
  * with the same options and value, so the reader can still answer; a badge goes into its
17
22
  * option's label ("Acme (Recommended)"); a description is dropped.
18
23
  */
19
- export type UiFeature = 'breadcrumbs' | 'button.disabled' | 'section.row' | 'form.field_kinds' | 'form.confirm' | 'form.radio';
24
+ export type UiFeature = 'breadcrumbs' | 'button.disabled' | 'section.row' | 'form.field_kinds' | 'form.confirm' | 'press.chat' | 'form.radio';
20
25
  /** The node types and features one ui-sdk release, or one client, draws. */
21
26
  export interface NodeSet {
22
27
  /** For messages: "ui-sdk 1.4.0", "mobile 0.2.5". */
@@ -53,7 +58,7 @@ export declare const UI_SDK_SNAPSHOTS: {
53
58
  readonly current: {
54
59
  readonly name: "ui-sdk (this package)";
55
60
  readonly nodes: readonly ["heading", "text", "markdown", "stat", "button", "form", "table", "timeline", "pending_request", "pending_requests", "choice_cards", "progress", "chart", "section", "tabs", "pagination", "select", "alert", "details", "timestamp", "divider", "board", "link", "tags", "toggle", "segmented", "progress_bar", "conversation", "composer", "calendar", "image", "video"];
56
- readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm", "form.radio"];
61
+ readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm", "press.chat", "form.radio"];
57
62
  };
58
63
  };
59
64
  export type UiSdkSnapshot = keyof typeof UI_SDK_SNAPSHOTS;
@@ -129,6 +134,10 @@ export declare const SAFETY_FALLBACK_TEXT = "Open this in the web app to finish
129
134
  * returned as the same object.
130
135
  */
131
136
  export declare function negotiateTree(tree: ScreenTree, set: NodeSet): NegotiatedTree;
137
+ /** True for a press that opens the chat with a prompt typed in. */
138
+ export declare function isChatPress(press: {
139
+ kind: string;
140
+ } | undefined): press is ChatPress;
132
141
  type FormNode = Extract<ScreenRootNode, {
133
142
  type: 'form';
134
143
  }>;
package/dist/negotiate.js CHANGED
@@ -32,7 +32,11 @@ const FEATURES_1_4_0 = [
32
32
  'form.confirm',
33
33
  ];
34
34
  /** Every feature: what this package parses and core's own renderer draws. */
35
- const ALL_FEATURES = [...FEATURES_1_4_0, 'form.radio'];
35
+ const ALL_FEATURES = [
36
+ ...FEATURES_1_4_0,
37
+ 'press.chat',
38
+ 'form.radio',
39
+ ];
36
40
  /** The nodes of ui-sdk 1.1.0 and 1.2.0 (one schema). */
37
41
  const NODES_1_1_0 = [
38
42
  'heading',
@@ -226,13 +230,19 @@ export function negotiateTree(tree, set) {
226
230
  // The zone the screen's times are drawn in (core fills in the Company's when the module named
227
231
  // none). A stand-in line writes its times in it, read before a fit may take the field away.
228
232
  const zone = tree.timeZone;
229
- const visit = (node, path) => {
230
- const loose = node;
233
+ const visit = (original, path) => {
234
+ const loose = original;
231
235
  if (!nodes.has(loose.type)) {
232
- const replacement = fallbackNode(node, zone);
236
+ const replacement = fallbackNode(original, zone);
233
237
  fallbacks.push({ path, type: loose.type, reason: 'node', as: replacement.type });
234
238
  return replacement;
235
239
  }
240
+ // A client that cannot open its chat gets no control that offers to.
241
+ const node = features.has('press.chat')
242
+ ? original
243
+ : withoutChatPresses(original, path, fallbacks);
244
+ if (node !== original && node.type === 'text')
245
+ return node;
236
246
  switch (node.type) {
237
247
  case 'button':
238
248
  if (node.disabled && !features.has('button.disabled')) {
@@ -328,16 +338,17 @@ export function negotiateTree(tree, set) {
328
338
  const children = visitAll(tree.children, 'children');
329
339
  if (children !== tree.children)
330
340
  next = { ...next, children };
331
- if (tree.actions && !features.has('button.disabled')) {
341
+ if (tree.actions && (!features.has('button.disabled') || !features.has('press.chat'))) {
342
+ // The header holds buttons only, so one the client cannot draw safely is dropped.
332
343
  const kept = tree.actions.filter((action, index) => {
333
- if (!action.disabled)
344
+ const reason = action.disabled && !features.has('button.disabled')
345
+ ? 'button.disabled'
346
+ : isChatPress(action.onPress) && !features.has('press.chat')
347
+ ? 'press.chat'
348
+ : null;
349
+ if (!reason)
334
350
  return true;
335
- fallbacks.push({
336
- path: `actions[${index}]`,
337
- type: 'button',
338
- reason: 'button.disabled',
339
- as: 'dropped',
340
- });
351
+ fallbacks.push({ path: `actions[${index}]`, type: 'button', reason, as: 'dropped' });
341
352
  return false;
342
353
  });
343
354
  if (kept.length !== tree.actions.length) {
@@ -389,6 +400,124 @@ export function negotiateTree(tree, set) {
389
400
  fallbacks: [...fallbacks, ...conformed.fallbacks],
390
401
  };
391
402
  }
403
+ /** True for a press that opens the chat with a prompt typed in. */
404
+ export function isChatPress(press) {
405
+ return press?.kind === 'chat';
406
+ }
407
+ /**
408
+ * The node as a client that cannot open its chat should get it: no control left on it that offers
409
+ * to (see `press.chat` above). Only the node's own presses; its child nodes are visited on their
410
+ * own. Returns the same object when there is nothing to take away.
411
+ */
412
+ function withoutChatPresses(node, path, fallbacks) {
413
+ const dropped = (at, type, as = 'dropped') => fallbacks.push({ path: at, type, reason: 'press.chat', as });
414
+ // A list of buttons without the ones that open the chat, or the same list when none does.
415
+ const keepButtons = (list, at) => {
416
+ if (!list?.some((button) => isChatPress(button.onPress)))
417
+ return list;
418
+ return list.filter((button, index) => {
419
+ if (!isChatPress(button.onPress))
420
+ return true;
421
+ dropped(`${at}[${index}]`, 'button');
422
+ return false;
423
+ });
424
+ };
425
+ switch (node.type) {
426
+ case 'button':
427
+ if (!isChatPress(node.onPress))
428
+ return node;
429
+ dropped(path, 'button', 'text');
430
+ return { type: 'text', value: clip(node.label, TEXT_MAX), muted: true };
431
+ case 'alert':
432
+ if (!node.action || !isChatPress(node.action.onPress))
433
+ return node;
434
+ dropped(`${path}.action`, 'button');
435
+ return omit(node, 'action');
436
+ case 'image':
437
+ if (!isChatPress(node.onPress))
438
+ return node;
439
+ dropped(`${path}.onPress`, 'image');
440
+ return omit(node, 'onPress');
441
+ case 'choice_cards': {
442
+ if (!node.choices.some((choice) => isChatPress(choice.onPress)))
443
+ return node;
444
+ const choices = node.choices.filter((choice, index) => {
445
+ if (!isChatPress(choice.onPress))
446
+ return true;
447
+ dropped(`${path}.choices[${index}]`, 'choice_cards');
448
+ return false;
449
+ });
450
+ if (choices.length > 0)
451
+ return { ...node, choices };
452
+ dropped(path, 'choice_cards', 'text');
453
+ const titles = node.choices.map((choice) => choice.title).join(', ');
454
+ return { type: 'text', value: clip(titles, TEXT_MAX), muted: true };
455
+ }
456
+ case 'board': {
457
+ let changed = false;
458
+ const columns = node.columns.map((column, c) => {
459
+ if (!column.cards.some((card) => isChatPress(card.onPress)))
460
+ return column;
461
+ changed = true;
462
+ const cards = column.cards.map((card, i) => {
463
+ if (!isChatPress(card.onPress))
464
+ return card;
465
+ dropped(`${path}.columns[${c}].cards[${i}].onPress`, 'board');
466
+ return omit(card, 'onPress');
467
+ });
468
+ return { ...column, cards };
469
+ });
470
+ return changed ? { ...node, columns } : node;
471
+ }
472
+ case 'calendar': {
473
+ let changed = false;
474
+ const events = node.events.map((event, i) => {
475
+ const at = `${path}.events[${i}]`;
476
+ const actions = keepButtons(event.actions, `${at}.actions`);
477
+ const press = isChatPress(event.onPress);
478
+ if (actions === event.actions && !press)
479
+ return event;
480
+ changed = true;
481
+ if (press)
482
+ dropped(`${at}.onPress`, 'calendar');
483
+ return withPresses(event, actions, press);
484
+ });
485
+ return changed ? { ...node, events } : node;
486
+ }
487
+ case 'table': {
488
+ let changed = false;
489
+ const rows = node.rows.map((row, i) => {
490
+ const at = `${path}.rows[${i}]`;
491
+ const actions = keepButtons(row.actions, `${at}.actions`);
492
+ const press = isChatPress(row.onPress);
493
+ if (actions === row.actions && !press)
494
+ return row;
495
+ changed = true;
496
+ if (press)
497
+ dropped(`${at}.onPress`, 'table');
498
+ return withPresses(row, actions, press);
499
+ });
500
+ return changed ? { ...node, rows } : node;
501
+ }
502
+ default:
503
+ return node;
504
+ }
505
+ }
506
+ /** A copy of `value` without `key`. */
507
+ function omit(value, key) {
508
+ const copy = { ...value };
509
+ delete copy[key];
510
+ return copy;
511
+ }
512
+ /** A row or entry with its kept buttons (none: no `actions`) and without its press when `drop`. */
513
+ function withPresses(item, actions, drop) {
514
+ const next = { ...item, actions };
515
+ if (!actions || actions.length === 0)
516
+ delete next.actions;
517
+ if (drop)
518
+ delete next.onPress;
519
+ return next;
520
+ }
392
521
  /** The form field kinds every client's parse knows (ui-sdk 1.1.0 onwards). */
393
522
  const OLDER_FIELD_KINDS = new Set(['text', 'textarea', 'select']);
394
523
  /** True when any option of the field carries a badge or a description. */
package/dist/pager.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Press } from './schema.js';
1
+ import type { ValuePress } from './schema.js';
2
2
  /**
3
3
  * The press a pager or select fires once the user has chosen `value`: the
4
4
  * declared press with the value merged in under `name` — into `params` for a
@@ -6,7 +6,7 @@ import type { Press } from './schema.js';
6
6
  * `input` for an action. The chosen value wins over a same-named key the
7
7
  * author put there, since the author cannot know which page will be chosen.
8
8
  */
9
- export declare function pressWithValue(press: Press, name: string, value: string | number): Press;
9
+ export declare function pressWithValue(press: ValuePress, name: string, value: string | number): ValuePress;
10
10
  /**
11
11
  * The page numbers a compact pager draws, `null` marking an ellipsis:
12
12
  * `pageWindow(5, 13)` → `[1, null, 4, 5, 6, null, 13]`. First and last pages
package/dist/schema.d.ts CHANGED
@@ -12,7 +12,45 @@
12
12
  */
13
13
  import { z } from 'zod';
14
14
  export declare const UI_SCHEMA_VERSION = 1;
15
- /** What a button (or table row) does when pressed. */
15
+ /**
16
+ * Opens the chat with `prompt` already typed in the box, and stops there. It
17
+ * NEVER sends: the reader reads the words, changes them if they like, and
18
+ * presses send themselves. "Ask Operator", "Do it with @csm", a walk-through
19
+ * chip on My Day.
20
+ *
21
+ * `prompt` is plain text the module wrote. A renderer puts it in the chat's
22
+ * text box as it is: never as HTML or markdown, and never over words the
23
+ * reader has already typed there. `agent` is the @handle of the team the chat
24
+ * is for ("csm"), the same name a reader types after "@"; without it the
25
+ * chat is with the Operator. It is a request, not a grant: the chat routes to
26
+ * that team only when the reader can use it, and the module learns nothing
27
+ * from the press (nothing is posted to it).
28
+ */
29
+ export declare const chatPressSchema: z.ZodObject<{
30
+ kind: z.ZodLiteral<"chat">;
31
+ prompt: z.ZodString;
32
+ agent: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ /**
35
+ * What a control that applies a chosen value calls: a pager, a select, a
36
+ * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
37
+ * so only an action or a navigate can carry it; a chat press cannot.
38
+ */
39
+ export declare const valuePressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
+ kind: z.ZodLiteral<"action">;
41
+ action: z.ZodString;
42
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
+ confirm: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ kind: z.ZodLiteral<"navigate">;
46
+ screen: z.ZodString;
47
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
48
+ }, z.core.$strip>], "kind">;
49
+ /**
50
+ * What a button (or table row, card, choice, calendar entry, image) does when
51
+ * pressed: call an action, open another screen of the module, or open the chat
52
+ * with a prompt typed in (`chat`, never sent).
53
+ */
16
54
  export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
55
  kind: z.ZodLiteral<"action">;
18
56
  action: z.ZodString;
@@ -22,6 +60,10 @@ export declare const pressSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
22
60
  kind: z.ZodLiteral<"navigate">;
23
61
  screen: z.ZodString;
24
62
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
63
+ }, z.core.$strip>, z.ZodObject<{
64
+ kind: z.ZodLiteral<"chat">;
65
+ prompt: z.ZodString;
66
+ agent: z.ZodOptional<z.ZodString>;
25
67
  }, z.core.$strip>], "kind">;
26
68
  /**
27
69
  * How a screen writes its dates and times. Set on the tree for the whole screen;
@@ -55,6 +97,10 @@ export declare const buttonSchema: z.ZodObject<{
55
97
  kind: z.ZodLiteral<"navigate">;
56
98
  screen: z.ZodString;
57
99
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ kind: z.ZodLiteral<"chat">;
102
+ prompt: z.ZodString;
103
+ agent: z.ZodOptional<z.ZodString>;
58
104
  }, z.core.$strip>], "kind">;
59
105
  variant: z.ZodDefault<z.ZodEnum<{
60
106
  destructive: "destructive";
@@ -151,6 +197,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
151
197
  kind: z.ZodLiteral<"navigate">;
152
198
  screen: z.ZodString;
153
199
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
200
+ }, z.core.$strip>, z.ZodObject<{
201
+ kind: z.ZodLiteral<"chat">;
202
+ prompt: z.ZodString;
203
+ agent: z.ZodOptional<z.ZodString>;
154
204
  }, z.core.$strip>], "kind">>;
155
205
  selected: z.ZodOptional<z.ZodBoolean>;
156
206
  }, z.core.$strip>, z.ZodObject<{
@@ -165,6 +215,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
165
215
  kind: z.ZodLiteral<"navigate">;
166
216
  screen: z.ZodString;
167
217
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
218
+ }, z.core.$strip>, z.ZodObject<{
219
+ kind: z.ZodLiteral<"chat">;
220
+ prompt: z.ZodString;
221
+ agent: z.ZodOptional<z.ZodString>;
168
222
  }, z.core.$strip>], "kind">;
169
223
  variant: z.ZodDefault<z.ZodEnum<{
170
224
  destructive: "destructive";
@@ -325,6 +379,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
325
379
  kind: z.ZodLiteral<"navigate">;
326
380
  screen: z.ZodString;
327
381
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
382
+ }, z.core.$strip>, z.ZodObject<{
383
+ kind: z.ZodLiteral<"chat">;
384
+ prompt: z.ZodString;
385
+ agent: z.ZodOptional<z.ZodString>;
328
386
  }, z.core.$strip>], "kind">>;
329
387
  expand: z.ZodOptional<z.ZodObject<{
330
388
  children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -372,6 +430,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
372
430
  kind: z.ZodLiteral<"navigate">;
373
431
  screen: z.ZodString;
374
432
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
433
+ }, z.core.$strip>, z.ZodObject<{
434
+ kind: z.ZodLiteral<"chat">;
435
+ prompt: z.ZodString;
436
+ agent: z.ZodOptional<z.ZodString>;
375
437
  }, z.core.$strip>], "kind">>;
376
438
  selected: z.ZodOptional<z.ZodBoolean>;
377
439
  }, z.core.$strip>, z.ZodObject<{
@@ -386,6 +448,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
386
448
  kind: z.ZodLiteral<"navigate">;
387
449
  screen: z.ZodString;
388
450
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
451
+ }, z.core.$strip>, z.ZodObject<{
452
+ kind: z.ZodLiteral<"chat">;
453
+ prompt: z.ZodString;
454
+ agent: z.ZodOptional<z.ZodString>;
389
455
  }, z.core.$strip>], "kind">;
390
456
  variant: z.ZodDefault<z.ZodEnum<{
391
457
  destructive: "destructive";
@@ -410,6 +476,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
410
476
  kind: z.ZodLiteral<"navigate">;
411
477
  screen: z.ZodString;
412
478
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
479
+ }, z.core.$strip>, z.ZodObject<{
480
+ kind: z.ZodLiteral<"chat">;
481
+ prompt: z.ZodString;
482
+ agent: z.ZodOptional<z.ZodString>;
413
483
  }, z.core.$strip>], "kind">;
414
484
  variant: z.ZodDefault<z.ZodEnum<{
415
485
  destructive: "destructive";
@@ -472,6 +542,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
472
542
  kind: z.ZodLiteral<"navigate">;
473
543
  screen: z.ZodString;
474
544
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
545
+ }, z.core.$strip>, z.ZodObject<{
546
+ kind: z.ZodLiteral<"chat">;
547
+ prompt: z.ZodString;
548
+ agent: z.ZodOptional<z.ZodString>;
475
549
  }, z.core.$strip>], "kind">;
476
550
  }, z.core.$strip>>;
477
551
  }, z.core.$strip>, z.ZodObject<{
@@ -583,6 +657,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
583
657
  kind: z.ZodLiteral<"navigate">;
584
658
  screen: z.ZodString;
585
659
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
660
+ }, z.core.$strip>, z.ZodObject<{
661
+ kind: z.ZodLiteral<"chat">;
662
+ prompt: z.ZodString;
663
+ agent: z.ZodOptional<z.ZodString>;
586
664
  }, z.core.$strip>], "kind">;
587
665
  variant: z.ZodDefault<z.ZodEnum<{
588
666
  destructive: "destructive";
@@ -708,6 +786,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
708
786
  kind: z.ZodLiteral<"navigate">;
709
787
  screen: z.ZodString;
710
788
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
789
+ }, z.core.$strip>, z.ZodObject<{
790
+ kind: z.ZodLiteral<"chat">;
791
+ prompt: z.ZodString;
792
+ agent: z.ZodOptional<z.ZodString>;
711
793
  }, z.core.$strip>], "kind">>;
712
794
  }, z.core.$strip>>;
713
795
  }, z.core.$strip>>;
@@ -949,6 +1031,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
949
1031
  kind: z.ZodLiteral<"navigate">;
950
1032
  screen: z.ZodString;
951
1033
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1034
+ }, z.core.$strip>, z.ZodObject<{
1035
+ kind: z.ZodLiteral<"chat">;
1036
+ prompt: z.ZodString;
1037
+ agent: z.ZodOptional<z.ZodString>;
952
1038
  }, z.core.$strip>], "kind">;
953
1039
  variant: z.ZodDefault<z.ZodEnum<{
954
1040
  destructive: "destructive";
@@ -969,6 +1055,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
969
1055
  kind: z.ZodLiteral<"navigate">;
970
1056
  screen: z.ZodString;
971
1057
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1058
+ }, z.core.$strip>, z.ZodObject<{
1059
+ kind: z.ZodLiteral<"chat">;
1060
+ prompt: z.ZodString;
1061
+ agent: z.ZodOptional<z.ZodString>;
972
1062
  }, z.core.$strip>], "kind">>;
973
1063
  }, z.core.$strip>>;
974
1064
  onSlotPress: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1013,6 +1103,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1013
1103
  kind: z.ZodLiteral<"navigate">;
1014
1104
  screen: z.ZodString;
1015
1105
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1106
+ }, z.core.$strip>, z.ZodObject<{
1107
+ kind: z.ZodLiteral<"chat">;
1108
+ prompt: z.ZodString;
1109
+ agent: z.ZodOptional<z.ZodString>;
1016
1110
  }, z.core.$strip>], "kind">>;
1017
1111
  }, z.core.$strip>, z.ZodObject<{
1018
1112
  type: z.ZodLiteral<"video">;
@@ -1178,6 +1272,10 @@ export declare const screenTreeSchema: z.ZodObject<{
1178
1272
  kind: z.ZodLiteral<"navigate">;
1179
1273
  screen: z.ZodString;
1180
1274
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1275
+ }, z.core.$strip>, z.ZodObject<{
1276
+ kind: z.ZodLiteral<"chat">;
1277
+ prompt: z.ZodString;
1278
+ agent: z.ZodOptional<z.ZodString>;
1181
1279
  }, z.core.$strip>], "kind">;
1182
1280
  variant: z.ZodDefault<z.ZodEnum<{
1183
1281
  destructive: "destructive";
@@ -1315,6 +1413,10 @@ export declare const actionResultSchema: z.ZodObject<{
1315
1413
  kind: z.ZodLiteral<"navigate">;
1316
1414
  screen: z.ZodString;
1317
1415
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1416
+ }, z.core.$strip>, z.ZodObject<{
1417
+ kind: z.ZodLiteral<"chat">;
1418
+ prompt: z.ZodString;
1419
+ agent: z.ZodOptional<z.ZodString>;
1318
1420
  }, z.core.$strip>], "kind">;
1319
1421
  variant: z.ZodDefault<z.ZodEnum<{
1320
1422
  destructive: "destructive";
@@ -1445,6 +1547,10 @@ export declare const jobStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1445
1547
  kind: z.ZodLiteral<"navigate">;
1446
1548
  screen: z.ZodString;
1447
1549
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1550
+ }, z.core.$strip>, z.ZodObject<{
1551
+ kind: z.ZodLiteral<"chat">;
1552
+ prompt: z.ZodString;
1553
+ agent: z.ZodOptional<z.ZodString>;
1448
1554
  }, z.core.$strip>], "kind">;
1449
1555
  variant: z.ZodDefault<z.ZodEnum<{
1450
1556
  destructive: "destructive";
@@ -1565,6 +1671,10 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
1565
1671
  kind: z.ZodLiteral<"navigate">;
1566
1672
  screen: z.ZodString;
1567
1673
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1674
+ }, z.core.$strip>, z.ZodObject<{
1675
+ kind: z.ZodLiteral<"chat">;
1676
+ prompt: z.ZodString;
1677
+ agent: z.ZodOptional<z.ZodString>;
1568
1678
  }, z.core.$strip>], "kind">;
1569
1679
  variant: z.ZodDefault<z.ZodEnum<{
1570
1680
  destructive: "destructive";
@@ -1710,6 +1820,8 @@ export declare const uiManifestSchema: z.ZodObject<{
1710
1820
  }, z.core.$strip>>;
1711
1821
  }, z.core.$strip>;
1712
1822
  export type Press = z.infer<typeof pressSchema>;
1823
+ export type ValuePress = z.infer<typeof valuePressSchema>;
1824
+ export type ChatPress = z.infer<typeof chatPressSchema>;
1713
1825
  export type ScreenPresentation = z.infer<typeof screenPresentationSchema>;
1714
1826
  export type ScreenTree = z.infer<typeof screenTreeSchema>;
1715
1827
  export type ActionResult = z.infer<typeof actionResultSchema>;
package/dist/schema.js CHANGED
@@ -22,22 +22,61 @@ const slug = z
22
22
  .string()
23
23
  .regex(/^[a-z][a-z0-9_-]*$/, 'lowercase slug (a-z, 0-9, -, _)')
24
24
  .max(64);
25
- /** What a button (or table row) does when pressed. */
25
+ const actionPressSchema = z.object({
26
+ kind: z.literal('action'),
27
+ /** Key into the screen's `actions` map on the module runtime. */
28
+ action: slug,
29
+ input: z.record(z.string(), z.unknown()).optional(),
30
+ /** If set, core shows this confirmation before dispatching. */
31
+ confirm: z.string().max(500).optional(),
32
+ });
33
+ const navigatePressSchema = z.object({
34
+ kind: z.literal('navigate'),
35
+ /** Another screen key of the same module. */
36
+ screen: slug,
37
+ params: z.record(z.string(), z.string()).optional(),
38
+ });
39
+ /**
40
+ * Opens the chat with `prompt` already typed in the box, and stops there. It
41
+ * NEVER sends: the reader reads the words, changes them if they like, and
42
+ * presses send themselves. "Ask Operator", "Do it with @csm", a walk-through
43
+ * chip on My Day.
44
+ *
45
+ * `prompt` is plain text the module wrote. A renderer puts it in the chat's
46
+ * text box as it is: never as HTML or markdown, and never over words the
47
+ * reader has already typed there. `agent` is the @handle of the team the chat
48
+ * is for ("csm"), the same name a reader types after "@"; without it the
49
+ * chat is with the Operator. It is a request, not a grant: the chat routes to
50
+ * that team only when the reader can use it, and the module learns nothing
51
+ * from the press (nothing is posted to it).
52
+ */
53
+ export const chatPressSchema = z.object({
54
+ kind: z.literal('chat'),
55
+ prompt: z
56
+ .string()
57
+ .min(1)
58
+ .max(2000)
59
+ .refine((value) => value.trim().length > 0, 'a prompt with words in it'),
60
+ agent: slug.optional(),
61
+ });
62
+ /**
63
+ * What a control that applies a chosen value calls: a pager, a select, a
64
+ * toggle, a sort or filter header. The value is merged in (`pressWithValue`),
65
+ * so only an action or a navigate can carry it; a chat press cannot.
66
+ */
67
+ export const valuePressSchema = z.discriminatedUnion('kind', [
68
+ actionPressSchema,
69
+ navigatePressSchema,
70
+ ]);
71
+ /**
72
+ * What a button (or table row, card, choice, calendar entry, image) does when
73
+ * pressed: call an action, open another screen of the module, or open the chat
74
+ * with a prompt typed in (`chat`, never sent).
75
+ */
26
76
  export const pressSchema = z.discriminatedUnion('kind', [
27
- z.object({
28
- kind: z.literal('action'),
29
- /** Key into the screen's `actions` map on the module runtime. */
30
- action: slug,
31
- input: z.record(z.string(), z.unknown()).optional(),
32
- /** If set, core shows this confirmation before dispatching. */
33
- confirm: z.string().max(500).optional(),
34
- }),
35
- z.object({
36
- kind: z.literal('navigate'),
37
- /** Another screen key of the same module. */
38
- screen: slug,
39
- params: z.record(z.string(), z.string()).optional(),
40
- }),
77
+ actionPressSchema,
78
+ navigatePressSchema,
79
+ chatPressSchema,
41
80
  ]);
42
81
  /**
43
82
  * The colour a block speaks in. `info` is the calm blue of a note; `accent` is
@@ -228,7 +267,7 @@ const paginationSchema = z
228
267
  pageCount: z.number().int().min(1).max(1_000_000),
229
268
  pageSize: z.number().int().min(1).max(10_000),
230
269
  total: z.number().int().min(0),
231
- onPage: pressSchema,
270
+ onPage: valuePressSchema,
232
271
  param: slug.default('page'),
233
272
  })
234
273
  .superRefine((node, ctx) => {
@@ -272,7 +311,7 @@ const selectSchema = z
272
311
  .array(z.object({ value: z.string().max(200), label: z.string().max(120) }))
273
312
  .min(1)
274
313
  .max(100),
275
- onChange: pressSchema,
314
+ onChange: valuePressSchema,
276
315
  disabled: z.boolean().default(false),
277
316
  /**
278
317
  * Where the label sits. `above` (the default) is a form field. `inline` puts
@@ -497,7 +536,7 @@ const calendarSchema = z
497
536
  date: z.iso.date(),
498
537
  /** The views the switch offers, in order. Without `onChange`, no switch. */
499
538
  views: z.array(z.enum(CALENDAR_VIEWS)).min(1).max(3).default(['day', 'week', 'month']),
500
- onChange: pressSchema.optional(),
539
+ onChange: valuePressSchema.optional(),
501
540
  /** The first and last hour the day and week views draw. Entries outside are clipped. */
502
541
  startHour: z.number().int().min(0).max(23).default(8),
503
542
  endHour: z.number().int().min(1).max(24).default(18),
@@ -526,7 +565,7 @@ const calendarSchema = z
526
565
  onPress: pressSchema.optional(),
527
566
  }))
528
567
  .max(500),
529
- onSlotPress: pressSchema.optional(),
568
+ onSlotPress: valuePressSchema.optional(),
530
569
  /** Shown when no entry falls in the view. */
531
570
  empty: z.string().min(1).max(80).default('Nothing booked'),
532
571
  /**
@@ -835,7 +874,7 @@ const toggleSchema = z.object({
835
874
  name: slug,
836
875
  label: z.string().min(1).max(80),
837
876
  value: z.boolean(),
838
- onChange: pressSchema,
877
+ onChange: valuePressSchema,
839
878
  disabled: z.boolean().default(false),
840
879
  /** A short explanation shown under the label. */
841
880
  hint: z.string().min(1).max(200).optional(),
@@ -862,7 +901,7 @@ const segmentedSchema = z
862
901
  }))
863
902
  .min(2)
864
903
  .max(6),
865
- onChange: pressSchema,
904
+ onChange: valuePressSchema,
866
905
  })
867
906
  .superRefine((node, ctx) => {
868
907
  if (!node.options.some((o) => o.value === node.value)) {
@@ -1179,7 +1218,7 @@ const leafNodeSchema = z.discriminatedUnion('type', [
1179
1218
  * action that returns `navigate` with the query in `params` (or filters
1180
1219
  * the same way), so those apps can still search.
1181
1220
  */
1182
- onChange: pressSchema.optional(),
1221
+ onChange: valuePressSchema.optional(),
1183
1222
  })
1184
1223
  .superRefine((node, ctx) => {
1185
1224
  if (node.onChange) {
@@ -1390,12 +1429,12 @@ const leafNodeSchema = z.discriminatedUnion('type', [
1390
1429
  * merged like the pager: into `params` for a navigate, `input` for an action.
1391
1430
  * The module sorts; the renderer never reorders rows itself.
1392
1431
  */
1393
- onSort: pressSchema.optional(),
1432
+ onSort: valuePressSchema.optional(),
1394
1433
  /**
1395
1434
  * A filter menu calls it with the column key set to the chosen value, ''
1396
1435
  * for All, merged like the pager. The module filters.
1397
1436
  */
1398
- onFilter: pressSchema.optional(),
1437
+ onFilter: valuePressSchema.optional(),
1399
1438
  rows: z
1400
1439
  .array(z.object({
1401
1440
  key: z.string().max(128),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/ui-sdk",
3
- "version": "1.5.0-dev-20261022115136",
3
+ "version": "1.5.0-dev-20261022120138",
4
4
  "description": "Product screens for keemakr marketplace modules: a versioned, server-driven UI tree schema plus defineScreen() handlers. Module code never ships to the browser — keemakr-core validates the tree and renders it with platform components.",
5
5
  "license": "MIT",
6
6
  "type": "module",