@adecore/intelligent-ui 0.23.1 → 0.24.1

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/catalog.d.ts CHANGED
@@ -34,8 +34,8 @@ export declare const UI_GROUPS: {
34
34
  readonly rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.';
35
35
  };
36
36
  readonly choices: {
37
- readonly description: 'Offer optional next steps after a finished answer.';
38
- readonly rules: 'Never ask for information or a decision needed before acting: use your own question tool if you have one, otherwise ask in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.';
37
+ readonly description: 'Offer shortcuts after finished work that the person may ignore.';
38
+ readonly rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.';
39
39
  };
40
40
  };
41
41
  export declare const UI_CATALOG: {
@@ -355,7 +355,7 @@ export declare const UI_CATALOG: {
355
355
  };
356
356
  readonly Choices: {
357
357
  readonly group: 'choices';
358
- readonly description: 'Optional next steps after a finished answer.';
358
+ readonly description: 'Shortcuts after finished work, never a question you wait on.';
359
359
  readonly schema: z.ZodObject<{}, z.core.$strict>;
360
360
  readonly children: readonly ['Choice'];
361
361
  };
package/dist/catalog.js CHANGED
@@ -23,8 +23,8 @@ export const UI_GROUPS = {
23
23
  rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.'
24
24
  },
25
25
  choices: {
26
- description: 'Offer optional next steps after a finished answer.',
27
- rules: 'Never ask for information or a decision needed before acting: use your own question tool if you have one, otherwise ask in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
26
+ description: 'Offer shortcuts after finished work that the person may ignore.',
27
+ rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
28
28
  }
29
29
  };
30
30
  export const UI_CATALOG = {
@@ -131,7 +131,7 @@ export const UI_CATALOG = {
131
131
  description: 'Repeat children over local data.',
132
132
  schema: z.strictObject({ items: z.array(z.unknown()).max(1000), as: name.regex(/^[A-Za-z_][A-Za-z_\d]*$/) })
133
133
  },
134
- Choices: { group: 'choices', description: 'Optional next steps after a finished answer.', schema: empty, children: ['Choice'] },
134
+ Choices: { group: 'choices', description: 'Shortcuts after finished work, never a question you wait on.', schema: empty, children: ['Choice'] },
135
135
  Choice: {
136
136
  group: 'choices',
137
137
  description: 'Send its label and visible context once.',
package/dist/query.d.ts CHANGED
@@ -3,5 +3,5 @@ import type { UiBlock } from './compiler.ts';
3
3
  import { type UiValue } from './expression.ts';
4
4
  import { UiState } from './runtime.ts';
5
5
  export declare function uiValidatedState(block: UiBlock, input?: Readonly<Record<string, unknown>>, queries?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits>): UiState;
6
- export declare function uiQueryArguments(block: UiBlock, name: string, input?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits>): Record<string, UiValue>;
6
+ export declare function uiQueryArguments(block: UiBlock, name: string, input?: Readonly<Record<string, unknown>>, limits?: Partial<UiLimits>, queries?: Readonly<Record<string, unknown>>): Record<string, UiValue>;
7
7
  export declare function uiQueryFallback(block: UiBlock, queries: Readonly<Record<string, unknown>>): string;
package/dist/query.js CHANGED
@@ -32,11 +32,16 @@ export function uiValidatedState(block, input = {}, queries = {}, limits = {}) {
32
32
  }
33
33
  return state;
34
34
  }
35
- export function uiQueryArguments(block, name, input = {}, limits = {}) {
35
+ /*
36
+ * `queries` are the readings the person saw, so an input chosen from options a query read is checked
37
+ * against them; without them such an input only passes as its default. The arguments themselves read
38
+ * only local state.
39
+ */
40
+ export function uiQueryArguments(block, name, input = {}, limits = {}, queries = {}) {
36
41
  if (!Object.hasOwn(block.queries, name)) {
37
42
  throw new UiFailure('invalid_query', 'This block does not declare that query.');
38
43
  }
39
- const state = uiValidatedState(block, input, {}, limits);
44
+ const state = uiValidatedState(block, input, queries, limits);
40
45
  const query = block.queries[name];
41
46
  return query.expression
42
47
  ? evaluateUiExpression(query.expression, state.scope(), new UiBudget(limits))
package/dist/text.js CHANGED
@@ -19,12 +19,11 @@ function uiExample(language) {
19
19
  '<Summary badge="Draft">Release overview</Summary>',
20
20
  '<Stats><Stat label="Tests" value={42}/></Stats>',
21
21
  '<Switch value={$enabled}>Notify me</Switch>',
22
- '<Choices><Choice context="Review the release overview">Continue</Choice></Choices>',
23
22
  '```'
24
23
  ].join('\n');
25
24
  }
26
25
  export function uiSessionNote({ fenceLanguage = UI_FENCE_LANGUAGE } = {}) {
27
- return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices only offer optional next steps after a finished answer; ask for information or a decision needed before acting with your own question tool if you have one, otherwise in prose. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
26
+ return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices are shortcuts after finished work that the person may ignore. When your turn would end waiting on the person (a missing fact, a decision, a go-ahead for work you would otherwise do), ask with your own question tool if you have one, otherwise in prose, never with Choices. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
28
27
  }
29
28
  export function uiReferenceText({ fenceLanguage = UI_FENCE_LANGUAGE } = {}) {
30
29
  const groups = Object.entries(UI_GROUPS)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/intelligent-ui",
3
- "version": "0.23.1",
3
+ "version": "0.24.1",
4
4
  "description": "A streaming UI catalog, compiler and bounded expression interpreter without a framework or DOM.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "Bas Milius",
package/src/catalog.ts CHANGED
@@ -27,8 +27,8 @@ export const UI_GROUPS = {
27
27
  rules: 'Bind value={$name}. A Button sets a literal with action={@Set($name, value)} or restores a default with {@Reset($name)} or {@Reset()}. State stays local until a Choice sends visible context.'
28
28
  },
29
29
  choices: {
30
- description: 'Offer optional next steps after a finished answer.',
31
- rules: 'Never ask for information or a decision needed before acting: use your own question tool if you have one, otherwise ask in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
30
+ description: 'Offer shortcuts after finished work that the person may ignore.',
31
+ rules: 'Never a question your turn waits on (a missing fact, a decision, a go-ahead for work you would otherwise do): ask that with your own question tool if you have one, otherwise in prose. Give a short label and precise visible context. A Choice sends once after streaming ends.'
32
32
  }
33
33
  } as const;
34
34
 
@@ -136,7 +136,7 @@ export const UI_CATALOG = {
136
136
  description: 'Repeat children over local data.',
137
137
  schema: z.strictObject({ items: z.array(z.unknown()).max(1000), as: name.regex(/^[A-Za-z_][A-Za-z_\d]*$/) })
138
138
  },
139
- Choices: { group: 'choices', description: 'Optional next steps after a finished answer.', schema: empty, children: ['Choice'] },
139
+ Choices: { group: 'choices', description: 'Shortcuts after finished work, never a question you wait on.', schema: empty, children: ['Choice'] },
140
140
  Choice: {
141
141
  group: 'choices',
142
142
  description: 'Send its label and visible context once.',
package/src/query.ts CHANGED
@@ -40,16 +40,22 @@ export function uiValidatedState(
40
40
  return state;
41
41
  }
42
42
 
43
+ /*
44
+ * `queries` are the readings the person saw, so an input chosen from options a query read is checked
45
+ * against them; without them such an input only passes as its default. The arguments themselves read
46
+ * only local state.
47
+ */
43
48
  export function uiQueryArguments(
44
49
  block: UiBlock,
45
50
  name: string,
46
51
  input: Readonly<Record<string, unknown>> = {},
47
- limits: Partial<UiLimits> = {}
52
+ limits: Partial<UiLimits> = {},
53
+ queries: Readonly<Record<string, unknown>> = {}
48
54
  ): Record<string, UiValue> {
49
55
  if (!Object.hasOwn(block.queries, name)) {
50
56
  throw new UiFailure('invalid_query', 'This block does not declare that query.');
51
57
  }
52
- const state = uiValidatedState(block, input, {}, limits);
58
+ const state = uiValidatedState(block, input, queries, limits);
53
59
  const query = block.queries[name];
54
60
  return query.expression
55
61
  ? (evaluateUiExpression(query.expression, state.scope(), new UiBudget(limits)) as Record<string, UiValue>)
package/src/text.ts CHANGED
@@ -27,13 +27,12 @@ function uiExample(language: string): string {
27
27
  '<Summary badge="Draft">Release overview</Summary>',
28
28
  '<Stats><Stat label="Tests" value={42}/></Stats>',
29
29
  '<Switch value={$enabled}>Notify me</Switch>',
30
- '<Choices><Choice context="Review the release overview">Continue</Choice></Choices>',
31
30
  '```'
32
31
  ].join('\n');
33
32
  }
34
33
 
35
34
  export function uiSessionNote({ fenceLanguage = UI_FENCE_LANGUAGE }: UiTextOptions = {}): string {
36
- return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices only offer optional next steps after a finished answer; ask for information or a decision needed before acting with your own question tool if you have one, otherwise in prose. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
35
+ return `${uiSyntax(fenceLanguage)} Prose outside. Only named catalog props, no styling. $name = literal JSON; input value={$name}; Button action={@Set($name, literal)}, {@Reset($name)} or {@Reset()} changes local state only; braced expressions: @Count, @Filter(list,row,predicate), @Sum, @Join, @Round. Show/Each control children. Choices are shortcuts after finished work that the person may ignore. When your turn would end waiting on the person (a missing fact, a decision, a go-ahead for work you would otherwise do), ask with your own question tool if you have one, otherwise in prose, never with Choices. Choice labels and precise context stay visible and send once. Image: attachment or generated="latest", never URL/path. No code execution. State resets on reload. Catalog (? means optional props): ${uiCompactCatalog()}\nExample:\n${uiExample(fenceLanguage)}\n`;
37
36
  }
38
37
 
39
38
  export function uiReferenceText({ fenceLanguage = UI_FENCE_LANGUAGE }: UiTextOptions = {}): string {