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

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/conform.js CHANGED
@@ -5,6 +5,8 @@
5
5
  //
6
6
  // 1. A value or shape the app's parse REFUSES fails the whole screen. Known ones are folded to the
7
7
  // nearest value the parse takes; anything else replaces the smallest node that holds it:
8
+ // - a chart's `chartType: 'area'` (after 1.4.0) -> 'line' (a chart's `stacked` and
9
+ // `legend` are stripped by such a parse, so its bars are drawn side by side)
8
10
  // - `tone: 'info' | 'accent'` (badge cells, tags, board columns, calendar entries, progress
9
11
  // bars; after 1.4.0) -> 'default', or the first tone that parse lists
10
12
  // - a string `min`/`max` on a date or datetime field (after 1.4.0) -> dropped
@@ -198,6 +200,17 @@ export function conformTree(tree, parser, options) {
198
200
  fallbacks.push({ path: pathText(path), type: 'tone', reason: 'parse', as: 'folded' });
199
201
  return true;
200
202
  }
203
+ if (key === 'chartType' &&
204
+ issue.code === 'invalid_value' &&
205
+ isObject(holder) &&
206
+ holder.type === 'chart' &&
207
+ holder.chartType === 'area' &&
208
+ (issue.values ?? []).includes('line')) {
209
+ // An area is a line with the room under it filled: the line keeps the trend.
210
+ holder.chartType = 'line';
211
+ fallbacks.push({ path: pathText(path), type: 'chartType', reason: 'parse', as: 'folded' });
212
+ return true;
213
+ }
201
214
  if ((key === 'min' || key === 'max') && isObject(holder) && key in holder) {
202
215
  delete holder[key];
203
216
  fallbacks.push({ path: pathText(path), type: String(key), reason: 'parse', as: 'folded' });
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<{
@@ -491,8 +565,11 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
491
565
  chartType: z.ZodEnum<{
492
566
  bar: "bar";
493
567
  line: "line";
568
+ area: "area";
494
569
  }>;
495
570
  title: z.ZodOptional<z.ZodString>;
571
+ stacked: z.ZodOptional<z.ZodBoolean>;
572
+ legend: z.ZodOptional<z.ZodBoolean>;
496
573
  orientation: z.ZodDefault<z.ZodEnum<{
497
574
  horizontal: "horizontal";
498
575
  vertical: "vertical";
@@ -583,6 +660,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
583
660
  kind: z.ZodLiteral<"navigate">;
584
661
  screen: z.ZodString;
585
662
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
663
+ }, z.core.$strip>, z.ZodObject<{
664
+ kind: z.ZodLiteral<"chat">;
665
+ prompt: z.ZodString;
666
+ agent: z.ZodOptional<z.ZodString>;
586
667
  }, z.core.$strip>], "kind">;
587
668
  variant: z.ZodDefault<z.ZodEnum<{
588
669
  destructive: "destructive";
@@ -708,6 +789,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
708
789
  kind: z.ZodLiteral<"navigate">;
709
790
  screen: z.ZodString;
710
791
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
792
+ }, z.core.$strip>, z.ZodObject<{
793
+ kind: z.ZodLiteral<"chat">;
794
+ prompt: z.ZodString;
795
+ agent: z.ZodOptional<z.ZodString>;
711
796
  }, z.core.$strip>], "kind">>;
712
797
  }, z.core.$strip>>;
713
798
  }, z.core.$strip>>;
@@ -949,6 +1034,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
949
1034
  kind: z.ZodLiteral<"navigate">;
950
1035
  screen: z.ZodString;
951
1036
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1037
+ }, z.core.$strip>, z.ZodObject<{
1038
+ kind: z.ZodLiteral<"chat">;
1039
+ prompt: z.ZodString;
1040
+ agent: z.ZodOptional<z.ZodString>;
952
1041
  }, z.core.$strip>], "kind">;
953
1042
  variant: z.ZodDefault<z.ZodEnum<{
954
1043
  destructive: "destructive";
@@ -969,6 +1058,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
969
1058
  kind: z.ZodLiteral<"navigate">;
970
1059
  screen: z.ZodString;
971
1060
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1061
+ }, z.core.$strip>, z.ZodObject<{
1062
+ kind: z.ZodLiteral<"chat">;
1063
+ prompt: z.ZodString;
1064
+ agent: z.ZodOptional<z.ZodString>;
972
1065
  }, z.core.$strip>], "kind">>;
973
1066
  }, z.core.$strip>>;
974
1067
  onSlotPress: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1013,6 +1106,10 @@ declare const leafNodeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1013
1106
  kind: z.ZodLiteral<"navigate">;
1014
1107
  screen: z.ZodString;
1015
1108
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1109
+ }, z.core.$strip>, z.ZodObject<{
1110
+ kind: z.ZodLiteral<"chat">;
1111
+ prompt: z.ZodString;
1112
+ agent: z.ZodOptional<z.ZodString>;
1016
1113
  }, z.core.$strip>], "kind">>;
1017
1114
  }, z.core.$strip>, z.ZodObject<{
1018
1115
  type: z.ZodLiteral<"video">;
@@ -1178,6 +1275,10 @@ export declare const screenTreeSchema: z.ZodObject<{
1178
1275
  kind: z.ZodLiteral<"navigate">;
1179
1276
  screen: z.ZodString;
1180
1277
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1278
+ }, z.core.$strip>, z.ZodObject<{
1279
+ kind: z.ZodLiteral<"chat">;
1280
+ prompt: z.ZodString;
1281
+ agent: z.ZodOptional<z.ZodString>;
1181
1282
  }, z.core.$strip>], "kind">;
1182
1283
  variant: z.ZodDefault<z.ZodEnum<{
1183
1284
  destructive: "destructive";
@@ -1315,6 +1416,10 @@ export declare const actionResultSchema: z.ZodObject<{
1315
1416
  kind: z.ZodLiteral<"navigate">;
1316
1417
  screen: z.ZodString;
1317
1418
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1419
+ }, z.core.$strip>, z.ZodObject<{
1420
+ kind: z.ZodLiteral<"chat">;
1421
+ prompt: z.ZodString;
1422
+ agent: z.ZodOptional<z.ZodString>;
1318
1423
  }, z.core.$strip>], "kind">;
1319
1424
  variant: z.ZodDefault<z.ZodEnum<{
1320
1425
  destructive: "destructive";
@@ -1445,6 +1550,10 @@ export declare const jobStatusSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1445
1550
  kind: z.ZodLiteral<"navigate">;
1446
1551
  screen: z.ZodString;
1447
1552
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1553
+ }, z.core.$strip>, z.ZodObject<{
1554
+ kind: z.ZodLiteral<"chat">;
1555
+ prompt: z.ZodString;
1556
+ agent: z.ZodOptional<z.ZodString>;
1448
1557
  }, z.core.$strip>], "kind">;
1449
1558
  variant: z.ZodDefault<z.ZodEnum<{
1450
1559
  destructive: "destructive";
@@ -1565,6 +1674,10 @@ export declare const screenLoadResponseSchema: z.ZodObject<{
1565
1674
  kind: z.ZodLiteral<"navigate">;
1566
1675
  screen: z.ZodString;
1567
1676
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1677
+ }, z.core.$strip>, z.ZodObject<{
1678
+ kind: z.ZodLiteral<"chat">;
1679
+ prompt: z.ZodString;
1680
+ agent: z.ZodOptional<z.ZodString>;
1568
1681
  }, z.core.$strip>], "kind">;
1569
1682
  variant: z.ZodDefault<z.ZodEnum<{
1570
1683
  destructive: "destructive";
@@ -1710,6 +1823,8 @@ export declare const uiManifestSchema: z.ZodObject<{
1710
1823
  }, z.core.$strip>>;
1711
1824
  }, z.core.$strip>;
1712
1825
  export type Press = z.infer<typeof pressSchema>;
1826
+ export type ValuePress = z.infer<typeof valuePressSchema>;
1827
+ export type ChatPress = z.infer<typeof chatPressSchema>;
1713
1828
  export type ScreenPresentation = z.infer<typeof screenPresentationSchema>;
1714
1829
  export type ScreenTree = z.infer<typeof screenTreeSchema>;
1715
1830
  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
@@ -152,8 +191,25 @@ const progressSchema = z.object({
152
191
  const chartSchema = z
153
192
  .object({
154
193
  type: z.literal('chart'),
155
- chartType: z.enum(['bar', 'line']),
194
+ /**
195
+ * `area` is a line with the room under it filled: a trend whose size matters, such as usage
196
+ * over 30 days. An app whose parse knows only `bar` and `line` gets an area as a line.
197
+ */
198
+ chartType: z.enum(['bar', 'line', 'area']),
156
199
  title: z.string().max(120).optional(),
200
+ /**
201
+ * Bars or areas of every series stacked on each other in one column (or one row, for
202
+ * horizontal bars), so the stack shows the total and each part of it: a revenue mix.
203
+ * `showValues` then writes the total at the end of each stack. Lines ignore it. An app that
204
+ * does not know it draws the series side by side.
205
+ */
206
+ stacked: z.boolean().optional(),
207
+ /**
208
+ * The key that names each series beside its colour. Shown by default. `false` hides it, but
209
+ * only on a one-series chart: with more series the key stays, so colour is never the only
210
+ * way to tell them apart.
211
+ */
212
+ legend: z.boolean().optional(),
157
213
  /**
158
214
  * Bars run up from the bottom (`vertical`) or along from the left
159
215
  * (`horizontal`). Horizontal bars put each category's name beside its bar,
@@ -228,7 +284,7 @@ const paginationSchema = z
228
284
  pageCount: z.number().int().min(1).max(1_000_000),
229
285
  pageSize: z.number().int().min(1).max(10_000),
230
286
  total: z.number().int().min(0),
231
- onPage: pressSchema,
287
+ onPage: valuePressSchema,
232
288
  param: slug.default('page'),
233
289
  })
234
290
  .superRefine((node, ctx) => {
@@ -272,7 +328,7 @@ const selectSchema = z
272
328
  .array(z.object({ value: z.string().max(200), label: z.string().max(120) }))
273
329
  .min(1)
274
330
  .max(100),
275
- onChange: pressSchema,
331
+ onChange: valuePressSchema,
276
332
  disabled: z.boolean().default(false),
277
333
  /**
278
334
  * Where the label sits. `above` (the default) is a form field. `inline` puts
@@ -497,7 +553,7 @@ const calendarSchema = z
497
553
  date: z.iso.date(),
498
554
  /** The views the switch offers, in order. Without `onChange`, no switch. */
499
555
  views: z.array(z.enum(CALENDAR_VIEWS)).min(1).max(3).default(['day', 'week', 'month']),
500
- onChange: pressSchema.optional(),
556
+ onChange: valuePressSchema.optional(),
501
557
  /** The first and last hour the day and week views draw. Entries outside are clipped. */
502
558
  startHour: z.number().int().min(0).max(23).default(8),
503
559
  endHour: z.number().int().min(1).max(24).default(18),
@@ -526,7 +582,7 @@ const calendarSchema = z
526
582
  onPress: pressSchema.optional(),
527
583
  }))
528
584
  .max(500),
529
- onSlotPress: pressSchema.optional(),
585
+ onSlotPress: valuePressSchema.optional(),
530
586
  /** Shown when no entry falls in the view. */
531
587
  empty: z.string().min(1).max(80).default('Nothing booked'),
532
588
  /**
@@ -835,7 +891,7 @@ const toggleSchema = z.object({
835
891
  name: slug,
836
892
  label: z.string().min(1).max(80),
837
893
  value: z.boolean(),
838
- onChange: pressSchema,
894
+ onChange: valuePressSchema,
839
895
  disabled: z.boolean().default(false),
840
896
  /** A short explanation shown under the label. */
841
897
  hint: z.string().min(1).max(200).optional(),
@@ -862,7 +918,7 @@ const segmentedSchema = z
862
918
  }))
863
919
  .min(2)
864
920
  .max(6),
865
- onChange: pressSchema,
921
+ onChange: valuePressSchema,
866
922
  })
867
923
  .superRefine((node, ctx) => {
868
924
  if (!node.options.some((o) => o.value === node.value)) {
@@ -1179,7 +1235,7 @@ const leafNodeSchema = z.discriminatedUnion('type', [
1179
1235
  * action that returns `navigate` with the query in `params` (or filters
1180
1236
  * the same way), so those apps can still search.
1181
1237
  */
1182
- onChange: pressSchema.optional(),
1238
+ onChange: valuePressSchema.optional(),
1183
1239
  })
1184
1240
  .superRefine((node, ctx) => {
1185
1241
  if (node.onChange) {
@@ -1390,12 +1446,12 @@ const leafNodeSchema = z.discriminatedUnion('type', [
1390
1446
  * merged like the pager: into `params` for a navigate, `input` for an action.
1391
1447
  * The module sorts; the renderer never reorders rows itself.
1392
1448
  */
1393
- onSort: pressSchema.optional(),
1449
+ onSort: valuePressSchema.optional(),
1394
1450
  /**
1395
1451
  * A filter menu calls it with the column key set to the chosen value, ''
1396
1452
  * for All, merged like the pager. The module filters.
1397
1453
  */
1398
- onFilter: pressSchema.optional(),
1454
+ onFilter: valuePressSchema.optional(),
1399
1455
  rows: z
1400
1456
  .array(z.object({
1401
1457
  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-20261022123413",
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",