@arkitektio/bsx 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/bsx/infer.d.ts.map +1 -1
  2. package/dist/bsx/infer.js +4 -0
  3. package/dist/bsx/infer.js.map +1 -1
  4. package/dist/bsx/language.js +3 -3
  5. package/dist/bsx/language.js.map +1 -1
  6. package/dist/bsx/parse.d.ts +1 -0
  7. package/dist/bsx/parse.d.ts.map +1 -1
  8. package/dist/bsx/parse.js +8 -1
  9. package/dist/bsx/parse.js.map +1 -1
  10. package/dist/bsx/print.d.ts.map +1 -1
  11. package/dist/bsx/print.js +2 -2
  12. package/dist/bsx/print.js.map +1 -1
  13. package/dist/bsx/references.d.ts +4 -0
  14. package/dist/bsx/references.d.ts.map +1 -1
  15. package/dist/bsx/references.js +47 -2
  16. package/dist/bsx/references.js.map +1 -1
  17. package/dist/ports/engine/defaultRegistry.d.ts.map +1 -1
  18. package/dist/ports/engine/defaultRegistry.js +2 -0
  19. package/dist/ports/engine/defaultRegistry.js.map +1 -1
  20. package/dist/ports/host.d.ts +6 -0
  21. package/dist/ports/host.d.ts.map +1 -1
  22. package/dist/ports/host.js.map +1 -1
  23. package/dist/ports/rekuest.d.ts +14 -1
  24. package/dist/ports/rekuest.d.ts.map +1 -1
  25. package/dist/ports/rekuest.js +1 -0
  26. package/dist/ports/rekuest.js.map +1 -1
  27. package/dist/ports/widgets/custom/PortBlokWidget.d.ts +30 -0
  28. package/dist/ports/widgets/custom/PortBlokWidget.d.ts.map +1 -0
  29. package/dist/ports/widgets/custom/PortBlokWidget.js +210 -0
  30. package/dist/ports/widgets/custom/PortBlokWidget.js.map +1 -0
  31. package/dist/ports.d.ts +2 -0
  32. package/dist/ports.d.ts.map +1 -1
  33. package/dist/ports.js +4 -0
  34. package/dist/ports.js.map +1 -1
  35. package/dist/renderer/BlokRenderer.d.ts +4 -1
  36. package/dist/renderer/BlokRenderer.d.ts.map +1 -1
  37. package/dist/renderer/BlokRenderer.js +5 -1
  38. package/dist/renderer/BlokRenderer.js.map +1 -1
  39. package/dist/renderer/bloks/control.d.ts +5 -0
  40. package/dist/renderer/bloks/control.d.ts.map +1 -1
  41. package/dist/renderer/bloks/control.js +41 -6
  42. package/dist/renderer/bloks/control.js.map +1 -1
  43. package/dist/renderer/bloks/port/host.d.ts +32 -0
  44. package/dist/renderer/bloks/port/host.d.ts.map +1 -0
  45. package/dist/renderer/bloks/port/host.js +14 -0
  46. package/dist/renderer/bloks/port/host.js.map +1 -0
  47. package/dist/renderer/runtime/context.d.ts +2 -0
  48. package/dist/renderer/runtime/context.d.ts.map +1 -1
  49. package/dist/renderer/runtime/context.js +4 -0
  50. package/dist/renderer/runtime/context.js.map +1 -1
  51. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  52. package/dist/renderer/runtime/hooks.js +1 -0
  53. package/dist/renderer/runtime/hooks.js.map +1 -1
  54. package/dist/renderer/runtime/resolution.d.ts +3 -0
  55. package/dist/renderer/runtime/resolution.d.ts.map +1 -1
  56. package/dist/renderer/runtime/resolution.js +17 -1
  57. package/dist/renderer/runtime/resolution.js.map +1 -1
  58. package/dist/renderer/runtime/types.d.ts +6 -0
  59. package/dist/renderer/runtime/types.d.ts.map +1 -1
  60. package/dist/renderer/runtime/types.js.map +1 -1
  61. package/dist/spec/bsx_v2.json +1517 -179
  62. package/dist/spec/catalogs/base@4.json +103 -3
  63. package/dist/spec/catalogs/base@4.json.js +103 -3
  64. package/dist/spec/vocabulary.d.ts +5 -1
  65. package/dist/spec/vocabulary.d.ts.map +1 -1
  66. package/dist/spec/vocabulary.js +4 -1
  67. package/dist/spec/vocabulary.js.map +1 -1
  68. package/dist/spec/vocabulary.json +50 -15
  69. package/dist/spec/vocabulary.json.js +50 -15
  70. package/package.json +1 -1
  71. package/src/bsx/infer.ts +4 -0
  72. package/src/bsx/language.ts +3 -3
  73. package/src/bsx/parse.ts +7 -1
  74. package/src/bsx/print.ts +2 -1
  75. package/src/bsx/references.test.ts +1 -1
  76. package/src/bsx/references.ts +45 -2
  77. package/src/ports/engine/defaultRegistry.tsx +2 -0
  78. package/src/ports/host.tsx +6 -0
  79. package/src/ports/rekuest.ts +7 -1
  80. package/src/ports/widgets/custom/PortBlokWidget.test.tsx +88 -0
  81. package/src/ports/widgets/custom/PortBlokWidget.tsx +268 -0
  82. package/src/ports.ts +4 -0
  83. package/src/renderer/BlokRenderer.tsx +9 -0
  84. package/src/renderer/bloks/control.tsx +65 -5
  85. package/src/renderer/bloks/flow.test.tsx +11 -0
  86. package/src/renderer/bloks/port/host.tsx +46 -0
  87. package/src/renderer/runtime/context.tsx +6 -0
  88. package/src/renderer/runtime/hooks.ts +1 -0
  89. package/src/renderer/runtime/resolution.ts +16 -1
  90. package/src/renderer/runtime/types.ts +6 -0
  91. package/src/spec/bsx_v2.json +1517 -179
  92. package/src/spec/catalogs/base@4.json +103 -3
  93. package/src/spec/spec.test.ts +8 -4
  94. package/src/spec/vocabulary.json +50 -15
  95. package/src/spec/vocabulary.ts +9 -2
@@ -2,7 +2,7 @@
2
2
  "id": "https://arkitekt.live/catalogs/base/v4",
3
3
  "name": "base",
4
4
  "version": 4,
5
- "minor": 0,
5
+ "minor": 2,
6
6
  "extends": null,
7
7
  "description": "The base catalog: everything every renderer draws. The language's own elements (control flow, async boundaries, the Blok element, the declarations, text), the html components, the structure and run parts a host supplies, the scene and the logo shapes. A renderer speaks it whole, in the contexts it draws; functions and effects are in vocabulary.json.",
8
8
  "components": [
@@ -30,7 +30,8 @@
30
30
  "custom",
31
31
  "task",
32
32
  "action",
33
- "assign"
33
+ "assign",
34
+ "port"
34
35
  ]
35
36
  },
36
37
  {
@@ -371,7 +372,7 @@
371
372
  {
372
373
  "name": "foreach",
373
374
  "group": "language",
374
- "description": "Renders its children once per item, the item bound to `let`; each item's subtree takes its ids from `key`, or from its position without one.",
375
+ "description": "Renders its children once per item, the item bound to `let` and its position to `index`; each item's subtree takes its ids from `key`, or from its position without one.",
375
376
  "context": "PANEL",
376
377
  "children_context": null,
377
378
  "inherits_context": true,
@@ -380,6 +381,13 @@
380
381
  "not_downstream_of": [],
381
382
  "text_prop": null,
382
383
  "props": [
384
+ {
385
+ "key": "index",
386
+ "kind": "STRING",
387
+ "required": false,
388
+ "description": "A name for the item's position, from 0 (`index=\"i\"`): a plain name, read bare inside.",
389
+ "since": 1
390
+ },
383
391
  {
384
392
  "key": "items",
385
393
  "kind": "ANY",
@@ -10656,6 +10664,98 @@
10656
10664
  "action"
10657
10665
  ]
10658
10666
  },
10667
+ {
10668
+ "name": "label",
10669
+ "group": "run",
10670
+ "description": "The port's label, as the form draws it. A port blok only: the form draws its own above the blok unless the blok places this one.",
10671
+ "context": "PANEL",
10672
+ "children_context": null,
10673
+ "inherits_context": false,
10674
+ "accepts_children": false,
10675
+ "downstream_of": [],
10676
+ "not_downstream_of": [],
10677
+ "text_prop": null,
10678
+ "props": [],
10679
+ "kinds": [
10680
+ "port"
10681
+ ],
10682
+ "since": 2
10683
+ },
10684
+ {
10685
+ "name": "description",
10686
+ "group": "run",
10687
+ "description": "The port's description, as the form draws it. A port blok only.",
10688
+ "context": "PANEL",
10689
+ "children_context": null,
10690
+ "inherits_context": false,
10691
+ "accepts_children": false,
10692
+ "downstream_of": [],
10693
+ "not_downstream_of": [],
10694
+ "text_prop": null,
10695
+ "props": [],
10696
+ "kinds": [
10697
+ "port"
10698
+ ],
10699
+ "since": 2
10700
+ },
10701
+ {
10702
+ "name": "message",
10703
+ "group": "run",
10704
+ "description": "What the form says is wrong with the port's value (`port.error`), as the form draws it; nothing while the value is fine. A port blok only: the form draws its own below the blok unless the blok places this one.",
10705
+ "context": "PANEL",
10706
+ "children_context": null,
10707
+ "inherits_context": false,
10708
+ "accepts_children": false,
10709
+ "downstream_of": [],
10710
+ "not_downstream_of": [],
10711
+ "text_prop": null,
10712
+ "props": [],
10713
+ "kinds": [
10714
+ "port"
10715
+ ],
10716
+ "since": 2
10717
+ },
10718
+ {
10719
+ "name": "control",
10720
+ "group": "run",
10721
+ "description": "The control the form would draw for this port without a blok: its kind's own, bound to the port. A port blok places it to draw around the standard control instead of replacing it. A port blok only.",
10722
+ "context": "PANEL",
10723
+ "children_context": null,
10724
+ "inherits_context": false,
10725
+ "accepts_children": false,
10726
+ "downstream_of": [],
10727
+ "not_downstream_of": [],
10728
+ "text_prop": null,
10729
+ "props": [],
10730
+ "kinds": [
10731
+ "port"
10732
+ ],
10733
+ "since": 2
10734
+ },
10735
+ {
10736
+ "name": "field",
10737
+ "group": "run",
10738
+ "description": "One child port of the port (a field of a MODEL), as its own widget draws it, bound below the port's value. A port blok only.",
10739
+ "context": "PANEL",
10740
+ "children_context": null,
10741
+ "inherits_context": false,
10742
+ "accepts_children": false,
10743
+ "downstream_of": [],
10744
+ "not_downstream_of": [],
10745
+ "text_prop": null,
10746
+ "props": [
10747
+ {
10748
+ "key": "key",
10749
+ "kind": "STRING",
10750
+ "required": true,
10751
+ "description": "The key of the child port."
10752
+ }
10753
+ ],
10754
+ "kinds": [
10755
+ "port"
10756
+ ],
10757
+ "since": 2
10758
+ },
10659
10759
  {
10660
10760
  "name": "Animate",
10661
10761
  "group": "scene",
@@ -49,10 +49,10 @@ describe('the synced vocabulary', () => {
49
49
  expect(vocabulary.callKinds).not.toContain('query_refetch');
50
50
  expect(vocabulary.records.query.fields.map(field => field.key)).toContain('fetching_more');
51
51
  expect(Object.keys(vocabulary.theme.dataAttributes).sort()).toEqual(['busy', 'stale']);
52
- expect([vocabulary.vocab, vocabulary.minor]).toEqual([2, 3]);
52
+ expect([vocabulary.vocab, vocabulary.minor]).toEqual([2, 5]);
53
53
  expect(vocabulary.baseCatalog).toBe('https://arkitekt.live/catalogs/base/v4');
54
54
  expect(Object.values(vocabulary.bundledCatalogs)).toEqual(['catalogs/base@4.json', 'catalogs/orkestrator@1.json']);
55
- expect(vocabulary.hostParts).toEqual(['args', 'arg', 'deps', 'dep', 'ask', 'returns', 'status', 'timeline']);
55
+ expect(vocabulary.hostParts).toEqual(['args', 'arg', 'deps', 'dep', 'ask', 'returns', 'status', 'timeline', 'label', 'description', 'message', 'control', 'field']);
56
56
  expect(vocabulary.unportableVariants.has('before')).toBe(true);
57
57
  expect(vocabulary.unportableVariants.has('hover')).toBe(false);
58
58
  });
@@ -76,7 +76,7 @@ describe('the synced vocabulary', () => {
76
76
  });
77
77
 
78
78
  it('fills diagnostic messages like str.format', () => {
79
- expect(diagnosticMessage('roots.reserved', {name: 'task'})).toBe("'task' is reserved: no local, let or into may use it.");
79
+ expect(diagnosticMessage('roots.reserved', {name: 'task'})).toBe("'task' is reserved: no local, let, index or into may use it.");
80
80
  expect(diagnosticMessage('local.bind', {what: 'x'})).toContain('{name}');
81
81
  });
82
82
 
@@ -171,6 +171,10 @@ describe('what a blok may do', () => {
171
171
  'task.step',
172
172
  ]);
173
173
  // What is left changes nothing but the viewer's own screen and clipboard.
174
- expect(effects.filter(fn => !fn.command).map(fn => fn.name).sort()).toEqual(['query.fetch_more', 'query.refetch', 'ui.copy']);
174
+ expect(effects.filter(fn => !fn.command).map(fn => fn.name).sort()).toEqual(['port.clear', 'port.reset', 'port.set', 'port.touch', 'query.fetch_more', 'query.refetch', 'ui.copy']);
175
+ // A root's own effects name the root a blok must read to hold them; a port blok is the one kind that calls no agent.
176
+ expect(effects.filter(fn => fn.needs !== null).map(fn => [fn.name, fn.needs])).toEqual([['port.set', 'port'], ['port.clear', 'port'], ['port.reset', 'port'], ['port.touch', 'port']]);
177
+ const kinds = loadVocabulary().kinds;
178
+ expect(Object.entries(kinds).filter(([, kind]) => !kind.calls).map(([name]) => name)).toEqual(['port']);
175
179
  });
176
180
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "vocab": 2,
3
- "minor": 3,
3
+ "minor": 5,
4
4
  "description": "The blok language, version 2: what a blok may read, call and store. The spec's parser, the server (rekuest_core, takt) and the renderer (orkestrator) load this file or are generated from it. The design is the blok-vocab-v2 proposal of 2026-10-25. Three layers, each versioned on its own: this language (vocab, and minor for what it gained since); the base catalog, everything every renderer draws; and the app catalogs that extend it with what one frontend draws beyond (see catalogs). A server holds a blok to the language alone, never to a catalog: whoever draws a blok checks it against the catalog it has, and an author's tooling checks it when asked.",
5
5
  "roots": {
6
6
  "data": {
@@ -8,9 +8,10 @@
8
8
  "deps": "deps.<key>: an agent bound to a dependency of the blok, a custom blok or an action.",
9
9
  "queries": "queries.<name>: a declared query's record (status, value, error, refetching, fetching_more).",
10
10
  "subscriptions": "subscriptions.<name>: a declared subscription's record (status, value, error); value is the latest payload, or the last `keep` payloads.",
11
- "args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok.",
11
+ "args": "args.<key>: what the blok is opened on: the item for an agent or custom blok, the task's args for a task or action blok, the form's other arguments as they are filled in for a port blok (read only).",
12
12
  "task": "The task this blok is about: the sending task, or the run. A task record.",
13
13
  "assign": "The run an assign blok prepares: assign.given.<key> (true for an argument the caller decided, which is locked), assign.missing (the keys of required arguments still empty) and assign.ready (nothing is missing).",
14
+ "port": "The port a port blok is the widget of: its value (port.value, which a control writes through bind) and what the form knows of it. A port record.",
14
15
  "event": "The payload a component hands its callback. Only inside a callback.",
15
16
  "viewer": "{user, org, roles} of whoever is looking.",
16
17
  "then": "The moment being viewed while time-travelling (an ISO 8601 datetime), null while live. A blok never reads the wall clock: a query passes then as an ordinary variable (variables={at: \"then\"}), <Time> measures relative time from it, and while it is set subscriptions pause (their history query, or the value at travel start, stale)."
@@ -22,7 +23,7 @@
22
23
  "functions": ["cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query"],
23
24
  "future": ["mutations"]
24
25
  },
25
- "reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
26
+ "reserved": ["self", "deps", "queries", "subscriptions", "args", "task", "assign", "port", "event", "viewer", "then", "error", "cmp", "logic", "math", "str", "list", "obj", "val", "fmt", "time", "ui", "query", "mutations"],
26
27
  "agent_segments": {
27
28
  "description": "What follows an agent (self or deps.<key>): .<state>.<field> is state, .tasks.<action> the latest task of that action, .assets.<name> one of the agent's assets; deps.<key>.<action>(...) calls it.",
28
29
  "tasks": "tasks",
@@ -61,6 +62,13 @@
61
62
  "roots": ["self", "deps", "args", "assign", "queries", "subscriptions", "viewer"],
62
63
  "locals": true,
63
64
  "contexts": ["PANEL", "SCENE"]
65
+ },
66
+ "port": {
67
+ "description": "A port's own widget, declared with the port: drawn in the action's form where the port's control would be. It is a field of that form: it reads the port, the form's other arguments as args and the state of the agents a run would get, and writes the port's value and nothing else. It calls no agent.",
68
+ "roots": ["self", "deps", "args", "port", "queries", "subscriptions", "viewer"],
69
+ "locals": true,
70
+ "contexts": ["PANEL"],
71
+ "calls": false
64
72
  }
65
73
  },
66
74
  "contexts": {
@@ -72,7 +80,7 @@
72
80
  "description": "Every blok is one <Blok> element that says what it is: its kind (what it reads, and where it may be mounted), its context (what host draws it), the catalog it is written for and whether the host draws its own chrome around it. What the blok owns is declared inside it (<local>, <query>, <subscription>); what its mount provides (deps, args, task, self's actions) is checked only where it is mounted.",
73
81
  "component": "Blok",
74
82
  "attributes": {
75
- "kind": "Required: agent, custom, task, action or assign (a row of kinds).",
83
+ "kind": "Required: agent, custom, task, action, assign or port (a row of kinds).",
76
84
  "context": "Required: panel, scene or logo.",
77
85
  "catalog": "The catalog it is written for (the address it is published at, or the name of one registered in the organization); the base catalog when left out.",
78
86
  "chrome": "\"none\": the host draws none of its own interface around the blok (panel and scene only)."
@@ -152,6 +160,26 @@
152
160
  {"key": "blocked", "kind": "STRING", "nullable": true, "description": "Why the run cannot start now, as a sentence (a dependency is not met, no agent fits); null when it can."}
153
161
  ]
154
162
  },
163
+ "port": {
164
+ "description": "What a port blok knows of the port it draws: its value, what the port declares, and where it stands in the form. Everything but value is the form's to say: a port blok sets no error and no flag.",
165
+ "fields": [
166
+ {"key": "value", "kind": "ANY", "nullable": true, "description": "The port's value as the form holds it, typed as the port; null while nothing is given. The one thing a port blok writes: a control through bind={port.value}, a callback with port.set(...)."},
167
+ {"key": "key", "kind": "STRING", "description": "The port's key."},
168
+ {"key": "label", "kind": "STRING", "nullable": true, "description": "What the form calls the port."},
169
+ {"key": "description", "kind": "STRING", "nullable": true},
170
+ {"key": "kind", "kind": "STRING", "description": "The port's kind (FLOAT, STRUCTURE, ...)."},
171
+ {"key": "identifier", "kind": "STRING", "nullable": true, "description": "The structure's identifier, for a STRUCTURE port."},
172
+ {"key": "nullable", "kind": "BOOL", "description": "Whether the port may be left empty."},
173
+ {"key": "default", "kind": "ANY", "nullable": true, "description": "What port.reset() goes back to."},
174
+ {"key": "choices", "kind": "LIST", "description": "The choices the port declares, each {value, label, description}; empty when it declares none."},
175
+ {"key": "unit", "kind": "STRING", "nullable": true, "description": "The unit a QUANTITY port's value is in."},
176
+ {"key": "editable", "kind": "BOOL", "description": "False where the value is only shown: the caller decided it, the form is locked or sent. A control bound to the port is then disabled, and port.set does nothing."},
177
+ {"key": "error", "kind": "STRING", "nullable": true, "description": "What the form says is wrong with the value, by the port's own rules (required, its kind, its validators); null when nothing is, or nothing was checked yet."},
178
+ {"key": "invalid", "kind": "BOOL", "description": "True while error is set."},
179
+ {"key": "touched", "kind": "BOOL", "description": "True once the viewer left the field (a bound control lost focus, or port.touch())."},
180
+ {"key": "dirty", "kind": "BOOL", "description": "True once the value differs from what the form opened with."}
181
+ ]
182
+ },
155
183
  "viewer": {
156
184
  "description": "Exposes nothing beyond what the viewer's own token says.",
157
185
  "fields": [
@@ -175,7 +203,7 @@
175
203
  "stale": "Known, but the source stopped updating (agent offline): the last value, flagged.",
176
204
  "failed": "Cannot be known (no access, agent gone, query error), with an error."
177
205
  },
178
- "always_ready": ["locals", "event", "let", "literals"],
206
+ "always_ready": ["locals", "event", "let", "index", "literals"],
179
207
  "propagation": [
180
208
  "If any input of an expression is pending, the result is pending; else if any failed, the result is failed; else if any is stale, the result is stale.",
181
209
  "logic.choose and <if> read only the branch taken; logic.all and logic.any stop at the first operand that decides them.",
@@ -187,7 +215,7 @@
187
215
  ]
188
216
  },
189
217
  "functions": {
190
- "description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, query.*). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
218
+ "description": "Pure functions by namespace, snake_case. Positional arguments map onto params in order. `lazy`: arguments are read only as needed. `effect`: allowed only as a callback's one thing (ui.*, task.*, assign.start, port.*, query.*). `needs`: the root a blok's kind must read to hold the effect (port.set needs port). `command`: an effect that changes the world (it acts on a task or starts one, and is recorded with it); an effect without it only changes what the viewer sees. A blok does nothing else: every other function is pure. `sees_status`: sees pending/failed instead of suspending. No function reads the wall clock. `null` says what the function does with a null argument (known absence); a missing path reads as null.",
191
219
  "cmp.eq": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Deep JSON equality.", "null": "null equals only null"},
192
220
  "cmp.ne": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "Not deep-equal.", "null": "null equals only null"},
193
221
  "cmp.gt": {"params": [["a", "ANY"], ["b", "ANY"]], "returns": "BOOL", "description": "a > b, numbers or strings.", "null": "false"},
@@ -313,6 +341,10 @@
313
341
  "task.step": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Resumes the run `task` is about until its next breakpoint. Refused while `task.can.step` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
314
342
  "task.interrupt": {"params": [], "returns": "ANY", "effect": true, "command": true, "task_operation": true, "description": "Interrupts the run `task` is about: stopped at once, without waiting for it to wind down. Refused while `task.can.interrupt` is false, and while the blok shows the past. Counts as a task operation.", "null": "takes no arguments"},
315
343
  "assign.start": {"params": [], "returns": "ANY", "effect": true, "command": true, "description": "Starts the run an assign blok prepares, with the arguments as they are filled in and the agents the blok was shown (deps) pinned. An assign blok only.", "null": "starts the run"},
344
+ "port.set": {"params": [["value", "ANY"]], "returns": "ANY", "effect": true, "needs": "port", "description": "Sets the port's value, as a control bound to it would: the form marks it dirty and checks it. A port blok only.", "null": "sets the port to empty, as port.clear() does"},
345
+ "port.clear": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Empties the port: nothing is given for it. A port blok only.", "null": "takes no arguments"},
346
+ "port.reset": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Puts the port back to what the form opened with (port.default when nothing was given), and clears touched and dirty. A port blok only.", "null": "takes no arguments"},
347
+ "port.touch": {"params": [], "returns": "ANY", "effect": true, "needs": "port", "description": "Says the viewer left the field: what a bound control says itself when it loses focus, for a control drawn by hand. A port blok only.", "null": "takes no arguments"},
316
348
  "query.refetch": {"params": [["query", "STRING"]], "returns": "ANY", "effect": true, "description": "Re-reads the declared query named by the literal `query`; never suspends, queries.<name>.refetching is true meanwhile. BSX writes it queries.<name>.refetch().", "null": "refused: the query is named by a literal"},
317
349
  "query.fetch_more": {"params": [["query", "STRING"], ["variables", "DICT", false]], "returns": "ANY", "effect": true, "description": "Reads the next page of the declared query named by the literal `query`, its variables overridden by `variables`, and appends the page's list at the query's `more` field to what is shown; queries.<name>.fetching_more is true meanwhile. BSX writes it queries.<name>.fetch_more(name: value, ...). Refused on a query without `more`.", "null": "refused: the query is named by a literal; null variables fetch with the query's own"}
318
350
  },
@@ -326,8 +358,8 @@
326
358
  "calls": {
327
359
  "description": "What a prop or an argument may hold besides a literal, a path or a util call.",
328
360
  "kinds": {
329
- "agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value).",
330
- "util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, query.refetch, query.fetch_more) as a callback's one thing."
361
+ "agent_call": "A task call: self.<action>(...) or deps.<key>.<action>(...), only as a callback's one thing, optionally named with `into <name>` (stored as the prop's declares_value). A kind that says calls: false (a port blok) holds none.",
362
+ "util_call": "A pure function, or an effect (ui.copy, task.answer, assign.start, port.set, query.refetch, query.fetch_more) as a callback's one thing."
331
363
  },
332
364
  "reserved_kinds": {
333
365
  "service_call": "Reserved for mutations, should they ever exist. Renderers refuse a call kind they do not know."
@@ -340,7 +372,7 @@
340
372
  "description": "How a v2 blok is stored: ComponentNodeInput {id, component, props?, children?}; ComponentPropInput {key, static_value? | dynamic_value {path} | util_call | agent_call (+ declares_value)}; ActionArgumentInput {key?, value_literal? | value_path? | util_call? | value_list? | value_dict?}. A prop or argument with no value field is null.",
341
373
  "ids": "An explicit id matches explicit_id; a derived id is the parent's id plus /<Component>[<n>] (n: occurrence among same-named siblings), the root's <Component>[0]. A derived id always ends in ']'. A text node is <parent>/#<n> (n: text-run index) and nothing may target it.",
342
374
  "explicit_id": "^[A-Za-z_][A-Za-z0-9_.:-]*$",
343
- "foreach": "foreach props: items (expression), let (static_value and declares_value the name), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
375
+ "foreach": "foreach props: items (expression), let (static_value and declares_value the name), index (optional; static_value and declares_value the name: an INT, the item's 0-based position in items, in scope where let is), key (expression, optional). With a key each item's subtree takes its runtime ids from it: <id>@<key>; without one, from its position: <id>@#<n> (n: the 0-based index). A foreach without key is stored with no key prop at all; the validator warns foreach.position_key when its items are known not to be scalars.",
344
376
  "if": "if props: when; children: the then-branch, then the else nodes (component else, an else-if with a when prop; only the last else may lack when).",
345
377
  "into": "agent_call prop with declares_value <name>: a task record only that call writes. Allowed inside foreach; one name is written by one call site.",
346
378
  "text": "Text is a child like any other: each run of text between elements is stored as a node {id: <parent>/#<n>, component: \"#text\", props: [value]}, its value a literal or an expression; several parts of one run desugar to str.template(template, values). No element can be called #text, so only text makes one. Parsing needs no catalog. What a component does with its text is its renderer's: one with a text_prop makes its text children that prop (a Button its label), any other that takes children draws them in place; a component that sets its text_prop as an attribute too, or takes neither text nor children, is a catalog finding (catalog.text). A tree stored before text was a node holds the text_prop itself, and implicit Text or span nodes under the same ids: a renderer draws both."
@@ -401,7 +433,7 @@
401
433
  "name": "^[A-Za-z_][A-Za-z0-9_.-]*$",
402
434
  "host_parts": {
403
435
  "description": "Parts of the host's own interface a blok may place itself: placing one anywhere in the tree claims it, and the host then draws none of its own. The claim is read off the stored tree, so a part inside an inactive <if> still claims it (part.conditional). What a blok does not place, the host still draws, unless its root says chrome=\"none\".",
404
- "parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline"]
436
+ "parts": ["args", "arg", "deps", "dep", "ask", "returns", "status", "timeline", "label", "description", "message", "control", "field"]
405
437
  }
406
438
  },
407
439
  "classes": {
@@ -424,7 +456,8 @@
424
456
  "bsx.text_callback": {"level": "error", "message": "Text holds a call or an effect; only a callback prop may.", "hint": "Put the call in a callback prop (onClick={{...}}), never between tags."},
425
457
  "bsx.else_outside_if": {"level": "error", "message": "<else> is a child of <if>, after its then-branch.", "hint": "Move the <else> inside its <if>, after the then-branch children."},
426
458
  "bsx.else_order": {"level": "error", "message": "<else> comes after the then-branch, and only the last <else> may lack when.", "hint": "Put the <else> branches last in the <if>; only the final one may leave out when."},
427
- "bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}} is optional): {missing}."},
459
+ "bsx.foreach": {"level": "error", "message": "<foreach> needs items={{...}} and let=\"name\" (key={{...}} and index=\"name\" are optional): {missing}."},
460
+ "bsx.index": {"level": "error", "message": "index={index!r} is not a name.", "hint": "Write index=\"i\": a plain identifier the children read as the item's position, from 0."},
428
461
  "bsx.let": {"level": "error", "message": "let={let!r} is not a name.", "hint": "Write let=\"name\": a plain identifier the children read as name.field."},
429
462
  "expr.syntax": {"level": "error", "message": "{detail}", "hint": "Expressions are a JavaScript subset: paths, literals, calls with name: value arguments, == != > >= < <=, && || !, ?? and c ? a : b."},
430
463
  "expr.arithmetic": {"level": "error", "message": "{operator} is not an operator of the blok language; call math.{function}(a, b)."},
@@ -443,11 +476,11 @@
443
476
  "callback.positional": {"level": "error", "message": "{call}: a task call names its arguments (name: value)."},
444
477
  "callback.into": {"level": "error", "message": "into names the record of a task call: `<call> into <name>`.", "hint": "Write `deps.<key>.<action>(name: value) into run`, then read run.running, run.returns.<port>."},
445
478
  "callback.not_callback": {"level": "error", "message": "{key} of <{component}> is not a callback prop, so it cannot hold {what}.", "hint": "Use a callback prop of <{component}> (the catalog lists them as CALLBACK), or compute {key} without a call."},
446
- "callback.unbound": {"level": "error", "message": "{key} of <{component}> is a callback prop: it holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
479
+ "callback.unbound": {"level": "error", "message": "{key} of <{component}> is a callback prop: it holds one task call or one effect (queries.<name>.refetch(), queries.<name>.fetch_more(...), ui.copy, task.answer, assign.start, port.set).", "hint": "Give {key} a task call (deps.<key>.<action>(name: value)) or one effect, not a value."},
447
480
  "callback.event_field": {"level": "error", "message": "event has no field {field!r} in {key} of <{component}> (its fields: {fields}).", "hint": "Read one of the fields listed for {key}: {fields}."},
448
- "roots.unknown": {"level": "error", "message": "{path} reads {root!r}, which is no root, local, loop variable or record of this blok.", "hint": "Read a root this blok has (deps.<key>, args.<key>, queries.<name>, ...), a declared local, a foreach let, or an into record."},
481
+ "roots.unknown": {"level": "error", "message": "{path} reads {root!r}, which is no root, local, loop variable or record of this blok.", "hint": "Read a root this blok has (deps.<key>, args.<key>, queries.<name>, ...), a declared local, a foreach let or index, or an into record."},
449
482
  "roots.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok has no {root!r} (it reads {roots}).", "hint": "Read one of {roots} instead."},
450
- "roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let or into may use it."},
483
+ "roots.reserved": {"level": "error", "message": "{name!r} is reserved: no local, let, index or into may use it."},
451
484
  "roots.shadow": {"level": "error", "message": "{name!r} is declared twice: as {first} and as {second}."},
452
485
  "roots.event_outside_callback": {"level": "error", "message": "{path} reads event outside a callback.", "hint": "Read event only inside a callback prop; outside one, bind a control to a local and read the local."},
453
486
  "roots.error_outside_boundary": {"level": "error", "message": "{path} reads error outside an <error> slot.", "hint": "Read error only inside the <error> slot of a <suspense>."},
@@ -461,6 +494,7 @@
461
494
  "args.unknown": {"level": "error", "message": "{path} reads args.{key}, which the blok does not declare (declared: {keys}).", "hint": "Read one of the declared args, or declare args.{key} (only when the user asks what the blok is opened for)."},
462
495
  "into.twice": {"level": "error", "message": "{name!r} is written by two calls: {first} and {second}. Each call site needs a record of its own."},
463
496
  "local.unknown": {"level": "error", "message": "bind={{{path}}} writes {root!r}, which is no declared local.", "hint": "Declare {root!r} in locals (its default, or null), then bind it."},
497
+ "port.bind": {"level": "error", "message": "bind={{{path}}}: a port blok writes port.value and nothing else of its port.", "hint": "Write bind={{port.value}}; what the form knows of the port (its label, its error) is the form's to say."},
464
498
  "local.bind": {"level": "error", "message": "bind holds a local's path ({{name}} or {{name.field}}), not {what}.", "hint": "Write bind={{name}} with a declared local's name."},
465
499
  "local.default": {"level": "error", "message": "local {name!r}: its default {default!r} is not a {kind}.", "hint": "Give a default of that kind, or leave the kind out so the default sets it."},
466
500
  "local.kind": {"level": "error", "message": "local {name!r}: type={type!r} is a name, not an annotation; give the type itself (int, list[str], a registered structure)."},
@@ -493,11 +527,12 @@
493
527
  "foreach.position_key": {"level": "warning", "message": "<foreach let=\"{let}\"> has no key, so its items are keyed by their position; they are not scalars, so key them by a stable field (key={{{let}.id}})."},
494
528
  "returns.unnamed": {"level": "warning", "message": "{path} reads {port}, a return the action left unnamed; name it in the action, as Annotated[T, Key(\"name\")] or as a field of a NamedTuple return, and read it by that name."},
495
529
  "blok.root": {"level": "error", "message": "A blok is one <Blok kind=... context=...> element, not <{component}>.", "hint": "Wrap it: <Blok kind=\"agent\" context=\"panel\">...</Blok>."},
496
- "blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign\" and context=\"panel|scene|logo\" as literals."},
530
+ "blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign|port\" and context=\"panel|scene|logo\" as literals."},
497
531
  "blok.content": {"level": "error", "message": "A {context} blok holds {expected} beside its declarations, not {found}.", "hint": "Put everything inside one {expected}."},
498
532
  "context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
499
533
  "kind.placement": {"level": "error", "message": "This is a{n} {kind} blok, but it is mounted as a{m} {expected} blok ({where}).", "hint": "Write kind=\"{expected}\" on its <Blok>, or mount it where a{n} {kind} blok goes."},
500
534
  "chrome.context": {"level": "error", "message": "chrome is the host's interface around a panel or a scene, not a {context} blok's.", "hint": "Drop chrome."},
535
+ "calls.not_in_kind": {"level": "error", "message": "{path}: a{n} {kind} blok calls no agent.", "hint": "A port blok is a field of a form: read the agent's state and write the port (port.set(...), bind={{port.value}}). What starts a task belongs in the action's assign blok."},
501
536
  "assign.kind": {"level": "error", "message": "{what} belongs to starting a run, so only an action's assign blok holds it, not a{n} {kind} blok.", "hint": "Make it <Blok kind=\"assign\"> in the action's bloks=[...]."},
502
537
  "logo.complexity": {"level": "error", "message": "{detail}"},
503
538
  "catalog.unknown_component": {"level": "warning", "message": "<{component}> is not in the catalog the blok is written for ({catalogs}).", "hint": "Look the component up in the catalog; names are case-sensitive."},
@@ -8,8 +8,8 @@ import vocabularyJson from './vocabulary.json';
8
8
  * diagnostics is read from this one file, never restated.
9
9
  */
10
10
 
11
- export type BlokKind = 'agent' | 'custom' | 'task' | 'action' | 'assign';
12
- export const BLOK_KINDS: readonly BlokKind[] = ['agent', 'custom', 'task', 'action', 'assign'];
11
+ export type BlokKind = 'agent' | 'custom' | 'task' | 'action' | 'assign' | 'port';
12
+ export const BLOK_KINDS: readonly BlokKind[] = ['agent', 'custom', 'task', 'action', 'assign', 'port'];
13
13
 
14
14
  export type BlokContextName = 'PANEL' | 'SCENE' | 'LOGO';
15
15
  export const BLOK_CONTEXTS: readonly BlokContextName[] = ['PANEL', 'SCENE', 'LOGO'];
@@ -30,6 +30,8 @@ export type VocabFunction = {
30
30
  command: boolean;
31
31
  /** Acts on the task the blok is about (`task.answer`, `task.cancel`): only where the blok reads one. */
32
32
  taskOperation: boolean;
33
+ /** The root a blok's kind must read to hold this effect (`port.set` needs `port`); null for none. */
34
+ needs: string | null;
33
35
  /** Sees a pending or failed argument instead of suspending. */
34
36
  seesStatus: boolean;
35
37
  /** The parameter names, in positional order. */
@@ -60,6 +62,8 @@ export type VocabKind = {
60
62
  contexts: readonly BlokContextName[];
61
63
  /** Per context, the narrower row the kind reads there (an action's logo reads only `task`, and has no locals). */
62
64
  within: Readonly<Partial<Record<BlokContextName, VocabKind>>>;
65
+ /** Whether a blok of this kind may call an agent (`self.<action>(...)`). A port blok may not: it is a field of a form. */
66
+ calls: boolean;
63
67
  };
64
68
 
65
69
  /** The row of `kind` in `context`: its own, or the narrower one it has there (vocabulary `kinds.<kind>.in`). */
@@ -300,6 +304,7 @@ const parseFunction = (name: string, raw: unknown): VocabFunction => {
300
304
  effect: entry.effect === true,
301
305
  command: entry.command === true,
302
306
  taskOperation: entry.task_operation === true,
307
+ needs: typeof entry.needs === 'string' ? entry.needs : null,
303
308
  seesStatus: entry.sees_status === true,
304
309
  keys: params.map(param => param.key),
305
310
  requiredKeys: params.filter(param => param.required).map(param => param.key),
@@ -327,6 +332,7 @@ export const parseVocabulary = (raw: unknown): BlokVocabulary => {
327
332
  locals: narrower.locals === true,
328
333
  contexts: [context],
329
334
  within: {},
335
+ calls: true,
330
336
  };
331
337
  }
332
338
  kinds[kind] = {
@@ -335,6 +341,7 @@ export const parseVocabulary = (raw: unknown): BlokVocabulary => {
335
341
  locals: entry.locals === true,
336
342
  contexts: strings(entry.contexts, `kinds.${kind}.contexts`).filter(isContext),
337
343
  within,
344
+ calls: entry.calls !== false,
338
345
  };
339
346
  }
340
347
  const unknownKinds = Object.keys(kindsRaw).filter(kind => kind !== 'description' && !(BLOK_KINDS as readonly string[]).includes(kind));