@arkitektio/bsx 5.0.0 → 6.0.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 (220) hide show
  1. package/README.md +2 -2
  2. package/dist/bsx/analyze.d.ts +6 -5
  3. package/dist/bsx/analyze.d.ts.map +1 -1
  4. package/dist/bsx/analyze.js +12 -10
  5. package/dist/bsx/analyze.js.map +1 -1
  6. package/dist/bsx/declared.d.ts +111 -0
  7. package/dist/bsx/declared.d.ts.map +1 -0
  8. package/dist/bsx/declared.js +311 -0
  9. package/dist/bsx/declared.js.map +1 -0
  10. package/dist/bsx/index.d.ts +1 -0
  11. package/dist/bsx/index.d.ts.map +1 -1
  12. package/dist/bsx/index.js +1 -0
  13. package/dist/bsx/index.js.map +1 -1
  14. package/dist/bsx/infer.d.ts +40 -17
  15. package/dist/bsx/infer.d.ts.map +1 -1
  16. package/dist/bsx/infer.js +105 -49
  17. package/dist/bsx/infer.js.map +1 -1
  18. package/dist/bsx/language.d.ts +6 -2
  19. package/dist/bsx/language.d.ts.map +1 -1
  20. package/dist/bsx/language.js +65 -21
  21. package/dist/bsx/language.js.map +1 -1
  22. package/dist/bsx/parse.d.ts +6 -1
  23. package/dist/bsx/parse.d.ts.map +1 -1
  24. package/dist/bsx/parse.js +32 -3
  25. package/dist/bsx/parse.js.map +1 -1
  26. package/dist/bsx/print.d.ts.map +1 -1
  27. package/dist/bsx/print.js +3 -0
  28. package/dist/bsx/print.js.map +1 -1
  29. package/dist/bsx/references.d.ts +45 -51
  30. package/dist/bsx/references.d.ts.map +1 -1
  31. package/dist/bsx/references.js +265 -138
  32. package/dist/bsx/references.js.map +1 -1
  33. package/dist/catalogs/html.d.ts +2 -2
  34. package/dist/catalogs/index.d.ts +49 -71
  35. package/dist/catalogs/index.d.ts.map +1 -1
  36. package/dist/catalogs/index.js +1 -1
  37. package/dist/catalogs/logo.d.ts +14 -28
  38. package/dist/catalogs/logo.d.ts.map +1 -1
  39. package/dist/catalogs/logo.js +1 -2
  40. package/dist/catalogs/logo.js.map +1 -1
  41. package/dist/catalogs/parts/data.d.ts +1 -1
  42. package/dist/catalogs/parts/feedback.d.ts +3 -3
  43. package/dist/catalogs/parts/forms.d.ts +4 -4
  44. package/dist/catalogs/parts/html.d.ts +2 -2
  45. package/dist/catalogs/parts/icons.d.ts +2 -2
  46. package/dist/catalogs/parts/index.d.ts +35 -57
  47. package/dist/catalogs/parts/index.d.ts.map +1 -1
  48. package/dist/catalogs/parts/logo.d.ts +10 -25
  49. package/dist/catalogs/parts/logo.d.ts.map +1 -1
  50. package/dist/catalogs/parts/logo.js +12 -14
  51. package/dist/catalogs/parts/logo.js.map +1 -1
  52. package/dist/catalogs/parts/navigation.d.ts +4 -4
  53. package/dist/catalogs/parts/overlays.d.ts +11 -11
  54. package/dist/catalogs/parts/run.d.ts +2 -10
  55. package/dist/catalogs/parts/run.d.ts.map +1 -1
  56. package/dist/catalogs/parts/scene.d.ts +7 -15
  57. package/dist/catalogs/parts/scene.d.ts.map +1 -1
  58. package/dist/catalogs/parts/scene.js +1 -5
  59. package/dist/catalogs/parts/scene.js.map +1 -1
  60. package/dist/catalogs/parts/typography.d.ts +3 -3
  61. package/dist/catalogs/props.d.ts +2 -2
  62. package/dist/catalogs/scene.d.ts +5 -13
  63. package/dist/catalogs/scene.d.ts.map +1 -1
  64. package/dist/catalogs/shadcn.d.ts +11 -11
  65. package/dist/catalogs/ui.d.ts +16 -16
  66. package/dist/logo/actionLogoSource.d.ts +3 -3
  67. package/dist/logo/actionLogoSource.d.ts.map +1 -1
  68. package/dist/logo/actionLogoSource.js +4 -4
  69. package/dist/logo/actionLogoSource.js.map +1 -1
  70. package/dist/renderer/BlokRenderer.d.ts +10 -6
  71. package/dist/renderer/BlokRenderer.d.ts.map +1 -1
  72. package/dist/renderer/BlokRenderer.js +23 -9
  73. package/dist/renderer/BlokRenderer.js.map +1 -1
  74. package/dist/renderer/baseCatalog.d.ts +3 -3
  75. package/dist/renderer/baseCatalog.js +2 -2
  76. package/dist/renderer/bloks/control.d.ts +18 -2
  77. package/dist/renderer/bloks/control.d.ts.map +1 -1
  78. package/dist/renderer/bloks/control.js +85 -14
  79. package/dist/renderer/bloks/control.js.map +1 -1
  80. package/dist/renderer/bloks/data.d.ts +1 -1
  81. package/dist/renderer/bloks/feedback.d.ts +3 -3
  82. package/dist/renderer/bloks/forms.d.ts +4 -4
  83. package/dist/renderer/bloks/html.d.ts +2 -2
  84. package/dist/renderer/bloks/icons.d.ts +1 -1
  85. package/dist/renderer/bloks/index.d.ts +30 -37
  86. package/dist/renderer/bloks/index.d.ts.map +1 -1
  87. package/dist/renderer/bloks/logo/index.d.ts +1 -8
  88. package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
  89. package/dist/renderer/bloks/logo/index.js +1 -2
  90. package/dist/renderer/bloks/logo/index.js.map +1 -1
  91. package/dist/renderer/bloks/logo/logo.fixture.json +266 -250
  92. package/dist/renderer/bloks/navigation.d.ts +4 -4
  93. package/dist/renderer/bloks/overlays.d.ts +11 -11
  94. package/dist/renderer/bloks/run/components.d.ts +1 -5
  95. package/dist/renderer/bloks/run/components.d.ts.map +1 -1
  96. package/dist/renderer/bloks/scene/index.d.ts +4 -8
  97. package/dist/renderer/bloks/scene/index.d.ts.map +1 -1
  98. package/dist/renderer/bloks/scene/interaction.d.ts.map +1 -1
  99. package/dist/renderer/bloks/scene/interaction.js +3 -2
  100. package/dist/renderer/bloks/scene/interaction.js.map +1 -1
  101. package/dist/renderer/bloks/shared/props.d.ts +2 -2
  102. package/dist/renderer/bloks/typography.d.ts +3 -3
  103. package/dist/renderer/declarations.d.ts +40 -33
  104. package/dist/renderer/declarations.d.ts.map +1 -1
  105. package/dist/renderer/declarations.js +41 -56
  106. package/dist/renderer/declarations.js.map +1 -1
  107. package/dist/renderer/declare.js +4 -4
  108. package/dist/renderer/declare.js.map +1 -1
  109. package/dist/renderer/persist.d.ts +22 -13
  110. package/dist/renderer/persist.d.ts.map +1 -1
  111. package/dist/renderer/persist.js +40 -21
  112. package/dist/renderer/persist.js.map +1 -1
  113. package/dist/renderer/runtime/catalog.d.ts +4 -4
  114. package/dist/renderer/runtime/catalog.js +3 -3
  115. package/dist/renderer/runtime/components.d.ts +4 -4
  116. package/dist/renderer/runtime/components.d.ts.map +1 -1
  117. package/dist/renderer/runtime/components.js +5 -5
  118. package/dist/renderer/runtime/components.js.map +1 -1
  119. package/dist/renderer/runtime/context.d.ts +5 -5
  120. package/dist/renderer/runtime/context.d.ts.map +1 -1
  121. package/dist/renderer/runtime/context.js +11 -5
  122. package/dist/renderer/runtime/context.js.map +1 -1
  123. package/dist/renderer/runtime/describe.d.ts +3 -3
  124. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  125. package/dist/renderer/runtime/describe.js +2 -2
  126. package/dist/renderer/runtime/describe.js.map +1 -1
  127. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  128. package/dist/renderer/runtime/hooks.js +8 -4
  129. package/dist/renderer/runtime/hooks.js.map +1 -1
  130. package/dist/renderer/runtime/index.d.ts +1 -0
  131. package/dist/renderer/runtime/index.d.ts.map +1 -1
  132. package/dist/renderer/runtime/index.js +1 -0
  133. package/dist/renderer/runtime/index.js.map +1 -1
  134. package/dist/renderer/runtime/locals.d.ts +57 -0
  135. package/dist/renderer/runtime/locals.d.ts.map +1 -0
  136. package/dist/renderer/runtime/locals.js +87 -0
  137. package/dist/renderer/runtime/locals.js.map +1 -0
  138. package/dist/renderer/runtime/scope.d.ts +14 -0
  139. package/dist/renderer/runtime/scope.d.ts.map +1 -1
  140. package/dist/renderer/runtime/scope.js +25 -3
  141. package/dist/renderer/runtime/scope.js.map +1 -1
  142. package/dist/renderer/runtime/tree.d.ts.map +1 -1
  143. package/dist/renderer/runtime/tree.js +7 -1
  144. package/dist/renderer/runtime/tree.js.map +1 -1
  145. package/dist/renderer/runtime/types.d.ts +8 -3
  146. package/dist/renderer/runtime/types.d.ts.map +1 -1
  147. package/dist/shadcn.d.ts +36 -43
  148. package/dist/shadcn.d.ts.map +1 -1
  149. package/dist/shadcn.js +1 -2
  150. package/dist/shadcn.js.map +1 -1
  151. package/dist/spec/bsx_v2.json +11067 -6321
  152. package/dist/spec/catalogs/{base@3.json → base@4.json} +434 -288
  153. package/dist/spec/catalogs/{base@3.json.js → base@4.json.js} +434 -288
  154. package/dist/spec/catalogs/orkestrator@1.json +10 -10
  155. package/dist/spec/catalogs/orkestrator@1.json.js +10 -10
  156. package/dist/spec/catalogs.d.ts +4 -4
  157. package/dist/spec/catalogs.d.ts.map +1 -1
  158. package/dist/spec/catalogs.js +7 -7
  159. package/dist/spec/catalogs.js.map +1 -1
  160. package/dist/spec/vocabulary.d.ts +25 -4
  161. package/dist/spec/vocabulary.d.ts.map +1 -1
  162. package/dist/spec/vocabulary.js +50 -5
  163. package/dist/spec/vocabulary.js.map +1 -1
  164. package/dist/spec/vocabulary.json +58 -32
  165. package/dist/spec/vocabulary.json.js +58 -32
  166. package/package.json +1 -1
  167. package/src/bsx/analyze.ts +14 -12
  168. package/src/bsx/bsx.test.ts +4 -4
  169. package/src/bsx/declared.ts +346 -0
  170. package/src/bsx/index.ts +1 -0
  171. package/src/bsx/infer.test.ts +42 -32
  172. package/src/bsx/infer.ts +128 -71
  173. package/src/bsx/language.test.ts +37 -25
  174. package/src/bsx/language.ts +72 -25
  175. package/src/bsx/parse.ts +34 -3
  176. package/src/bsx/print.ts +3 -0
  177. package/src/bsx/references.test.ts +82 -81
  178. package/src/bsx/references.ts +313 -178
  179. package/src/catalogs/catalogs.test.ts +3 -2
  180. package/src/catalogs/index.ts +1 -1
  181. package/src/catalogs/logo.ts +1 -2
  182. package/src/catalogs/parts/logo.ts +13 -17
  183. package/src/catalogs/parts/scene.ts +1 -7
  184. package/src/logo/actionLogoSource.ts +4 -4
  185. package/src/renderer/BlokComponentHost.test.tsx +5 -5
  186. package/src/renderer/BlokRenderer.tsx +46 -14
  187. package/src/renderer/addBlokComponents.test.tsx +1 -1
  188. package/src/renderer/baseCatalog.ts +2 -2
  189. package/src/renderer/bloks/control.tsx +119 -16
  190. package/src/renderer/bloks/logo/index.tsx +2 -3
  191. package/src/renderer/bloks/logo/logo.fixture.json +266 -250
  192. package/src/renderer/bloks/logo/logo.test.tsx +18 -7
  193. package/src/renderer/bloks/run/space.test.tsx +12 -4
  194. package/src/renderer/bloks/scene/interaction.tsx +11 -6
  195. package/src/renderer/bloks/scene/transform.test.ts +8 -7
  196. package/src/renderer/declarations.test.ts +38 -51
  197. package/src/renderer/declarations.ts +67 -88
  198. package/src/renderer/declare.test.ts +4 -4
  199. package/src/renderer/declare.ts +4 -4
  200. package/src/renderer/persist.test.ts +70 -49
  201. package/src/renderer/persist.ts +57 -34
  202. package/src/renderer/runtime/catalog.test.ts +2 -2
  203. package/src/renderer/runtime/catalog.ts +4 -4
  204. package/src/renderer/runtime/components.tsx +8 -8
  205. package/src/renderer/runtime/context.tsx +17 -10
  206. package/src/renderer/runtime/describe.ts +5 -5
  207. package/src/renderer/runtime/hooks.ts +6 -4
  208. package/src/renderer/runtime/index.ts +1 -0
  209. package/src/renderer/runtime/locals.tsx +105 -0
  210. package/src/renderer/runtime/scope.tsx +31 -3
  211. package/src/renderer/runtime/tree.tsx +16 -4
  212. package/src/renderer/runtime/types.ts +8 -3
  213. package/src/shadcn.ts +1 -2
  214. package/src/spec/bsx_v2.json +11067 -6321
  215. package/src/spec/catalogs/{base@3.json → base@4.json} +434 -288
  216. package/src/spec/catalogs/orkestrator@1.json +10 -10
  217. package/src/spec/catalogs.ts +8 -8
  218. package/src/spec/spec.test.ts +19 -16
  219. package/src/spec/vocabulary.json +58 -32
  220. package/src/spec/vocabulary.ts +69 -10
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "vocab": 2,
3
- "minor": 1,
3
+ "minor": 2,
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": {
@@ -35,47 +35,62 @@
35
35
  "description": "Declared by an app for its own agent (app.blok).",
36
36
  "roots": ["self", "args", "queries", "subscriptions", "viewer", "then"],
37
37
  "locals": true,
38
- "contexts": ["HTML", "SCENE", "LOGO"]
38
+ "contexts": ["PANEL", "SCENE", "LOGO"]
39
39
  },
40
40
  "custom": {
41
41
  "description": "Built by a user and materialized onto agents.",
42
42
  "roots": ["deps", "args", "queries", "subscriptions", "viewer", "then"],
43
43
  "locals": true,
44
- "contexts": ["HTML", "SCENE"]
44
+ "contexts": ["PANEL", "SCENE"]
45
45
  },
46
46
  "task": {
47
47
  "description": "A task's ask or inform blok; its dependencies are the sending task's, mapped.",
48
48
  "roots": ["self", "deps", "args", "task", "queries", "subscriptions", "viewer", "then"],
49
49
  "locals": true,
50
- "contexts": ["HTML"]
50
+ "contexts": ["PANEL"]
51
51
  },
52
52
  "action": {
53
- "description": "An action's own blok, declared inline with the action (ActionBlok); its dependencies are the action's.",
53
+ "description": "An action's own blok, declared with the action (bloks=); its dependencies are the action's. In the logo context it is the action's logo, drawn against the task the viewer last ran of it (null until then): it reads only task and declares nothing.",
54
54
  "roots": ["self", "deps", "args", "task", "queries", "subscriptions", "viewer", "then"],
55
55
  "locals": true,
56
- "contexts": ["HTML", "SCENE"]
56
+ "contexts": ["PANEL", "SCENE", "LOGO"],
57
+ "in": {"LOGO": {"roots": ["task"], "locals": false}}
57
58
  },
58
59
  "assign": {
59
- "description": "An action's own blok for starting a run of it (assign_bloks): shown before there is a task, with the arguments being filled in as args and the agents a run would get as deps.",
60
+ "description": "An action's own blok for starting a run of it (bloks=, kind assign): shown before there is a task, with the arguments being filled in as args and the agents a run would get as deps.",
60
61
  "roots": ["self", "deps", "args", "assign", "queries", "subscriptions", "viewer"],
61
62
  "locals": true,
62
- "contexts": ["HTML", "SCENE"]
63
- },
64
- "action_logo": {
65
- "description": "An action's logo, drawn against the task the viewer last ran of it (null until then).",
66
- "roots": ["task"],
67
- "locals": false,
68
- "contexts": ["LOGO"]
63
+ "contexts": ["PANEL", "SCENE"]
69
64
  }
70
65
  },
71
66
  "contexts": {
72
- "HTML": {"text": true, "description": "Panels, dashboards and popouts."},
67
+ "PANEL": {"text": true, "description": "Panels, dashboards and popouts: a flat rectangle the host lays out."},
73
68
  "SCENE": {"text": false, "description": "A 3D view: a Scene, or an action's Space, which places the run's dependencies in a room whose layout is shared."},
74
- "LOGO": {"text": false, "description": "An SVG drawing in the viewer's palette: an agent's logo, or an action's (an ACTION_LOGO blok is drawn in LOGO)."}
69
+ "LOGO": {"text": false, "description": "An SVG drawing in the viewer's palette: an agent's logo, or an action's (kind action), which paints with the palette's pens only."}
75
70
  },
76
- "blok_roots": {
77
- "description": "A blok's root component names its context: every blok starts with one of these, and nothing else declares the context.",
78
- "roots": {"Html": "HTML", "Scene": "SCENE", "Space": "SCENE", "AgentLogo": "LOGO", "ActionLogo": "ACTION_LOGO"}
71
+ "blok": {
72
+ "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
+ "component": "Blok",
74
+ "attributes": {
75
+ "kind": "Required: agent, custom, task, action or assign (a row of kinds).",
76
+ "context": "Required: panel, scene or logo.",
77
+ "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
+ "chrome": "\"none\": the host draws none of its own interface around the blok (panel and scene only)."
79
+ },
80
+ "contexts": {"panel": "PANEL", "scene": "SCENE", "logo": "LOGO"},
81
+ "content": {
82
+ "description": "Per context, the one element a blok holds besides its declarations; a panel holds any elements.",
83
+ "SCENE": ["Scene", "Space"],
84
+ "LOGO": ["Logo"]
85
+ },
86
+ "chrome": ["PANEL", "SCENE"],
87
+ "declarations": {
88
+ "description": "What a blok owns, declared in its tree. Each is stored as a node of its own and draws nothing.",
89
+ "local": "<local name=\"x\" default={...} persist kind=... />: a local (see locals). It comes before every other child of its parent and is in scope in its parent's subtree only; inside a foreach there is one per item. Every attribute but name is a literal: a port field (kind, identifier, nullable, choices, children, label, description, default, ...), persist, or like=\"self.<action>.<arg>\" / like=\"deps.<key>.<action>.<arg>\" (the port of that argument, resolved where the blok is mounted).",
90
+ "query": "<query name=\"x\" service=\"mikro\" document=\"query (...) {...}\" poll={5} more=\"items\"><var key=\"k\" value={...} /></query>: a declared read, queries.<name>. A child of <Blok>, before its content.",
91
+ "subscription": "<subscription name=\"x\" service=\"mikro\" document=\"subscription (...) {...}\" keep={10} history=\"q\"><var key=\"k\" value={...} /></subscription>: a declared stream, subscriptions.<name>. A child of <Blok>, before its content.",
92
+ "var": "<var key=\"k\" value={expression or literal} />: one variable of a query or subscription; an expression over args, blok-level locals and agents."
93
+ }
79
94
  },
80
95
  "records": {
81
96
  "task": {
@@ -324,10 +339,12 @@
324
339
  "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."
325
340
  },
326
341
  "locals": {
327
- "description": "Blok-level form state that feeds a call: a local is an arg port (key, kind, identifier, nullable, default, children, choices, validators, description, ...) plus persist, written only through `bind` on controls, read bare. persist remembers the last input on this device. Its kind is a port kind or ANY; left out on the wire it is inferred (kind_inference) and the stored local always carries one.",
342
+ "description": "Form state that feeds a call, declared in the tree as <local name=... />: a local is an arg port (key, kind, identifier, nullable, default, children, choices, validators, description, ...) plus persist, written only through `bind` on controls, read bare. persist remembers the last input on this device. Its kind is a port kind or ANY; left out it is inferred (kind_inference).",
328
343
  "fields": ["persist"],
344
+ "node": {"component": "local", "name": "name", "like": "like", "persist": "persist"},
345
+ "scope": "A local is in scope in its parent's subtree: its siblings, their children, and nothing outside its parent. It is the first of its parent's children (only other locals before it), never a child of a component that takes no children. Inside a foreach there is one value per item (by the item's runtime id); it lives as long as the blok is open, an if's branch closing and reopening included. A kept (persist) value is kept by the local's runtime id: an explicit id keeps it across edits of the tree. A local never shadows a name in scope (another local, a let, an into name) nor a reserved root.",
329
346
  "any": "ANY is a local's kind only (no action port is ever ANY): an untyped value. It is never an error and gets no warning; it skips the bind_kinds and arg_kinds checks and a path below it is taken as written. A renderer treats it as an untyped value.",
330
- "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "The SDK's Local[T]() / Local(type=T) and Local.like(action, arg) come before rule 1. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
347
+ "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "A given kind and like= come before rule 1. Only uses inside the local's scope (its parent's subtree) count. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
331
348
  "bind": "bind={<local>} or bind={<local>.<field>...}: the control writes the local; nothing else does. The catalog's kind of the bind prop is what the control writes: the local (or the field of it bound) must be a port kind bind_kinds lists for it.",
332
349
  "bind_kinds": {"description": "Per catalog kind of a bind prop, the port kinds of the locals it may write. A kind not listed (ANY) writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
333
350
  "arg_kinds": {"description": "Per port kind of a local passed whole as a task call's argument, the kinds of the action's arg port that take it, where the action is known (agent self.<action> demands, an action's dependencies). STRUCTURE also needs the same identifier. An ANY local is not checked.", "STRING": ["STRING"], "INT": ["INT", "FLOAT"], "FLOAT": ["FLOAT"], "BOOL": ["BOOL"], "ENUM": ["ENUM", "STRING"], "DATE": ["DATE", "STRING"], "QUANTITY": ["QUANTITY", "FLOAT"], "LIST": ["LIST"], "DICT": ["DICT"], "MODEL": ["MODEL", "DICT"], "STRUCTURE": ["STRUCTURE"]}
@@ -370,9 +387,9 @@
370
387
  "logo_path_data_props": ["d", "points"]
371
388
  },
372
389
  "catalogs": {
373
- "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (HTML, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
374
- "base": "https://arkitekt.live/catalogs/base/v3",
375
- "bundled": {"https://arkitekt.live/catalogs/base/v3": "catalogs/base@3.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
390
+ "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
391
+ "base": "https://arkitekt.live/catalogs/base/v4",
392
+ "bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
376
393
  "id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
377
394
  "name": "^[A-Za-z_][A-Za-z0-9_.-]*$",
378
395
  "host_parts": {
@@ -390,8 +407,8 @@
390
407
  "diagnostics": {
391
408
  "description": "One table of stable codes, the same in Python, Rust and TypeScript. level: error refuses the blok, warning is reported; runtime: true marks a code no checker raises, the renderer's error code of a record (deps.unbound). Messages are str.format templates; parity compares codes, never text.",
392
409
  "bsx.syntax": {"level": "error", "message": "{detail}", "hint": "Fix the markup at the line and column given; every attribute is name=\"text\" or name={{expression}}."},
393
- "bsx.empty": {"level": "error", "message": "A blok has one root element; this source has none.", "hint": "Write one root element, the one the blok's context names (<Html> for an html blok)."},
394
- "bsx.multiple_roots": {"level": "error", "message": "A blok has one root element; found another after it: <{component}>.", "hint": "Wrap everything in the one root element (<Html>...</Html>); siblings go inside it."},
410
+ "bsx.empty": {"level": "error", "message": "A blok has one root element; this source has none.", "hint": "Write one root element: <Blok kind=\"...\" context=\"...\">."},
411
+ "bsx.multiple_roots": {"level": "error", "message": "A blok has one root element; found another after it: <{component}>.", "hint": "Wrap everything in the one root element (<Blok ...>...</Blok>); siblings go inside it."},
395
412
  "bsx.unclosed": {"level": "error", "message": "<{component}> is never closed.", "hint": "Close it with </{component}>, or write it self-closing as <{component} ... />."},
396
413
  "bsx.mismatched_tag": {"level": "error", "message": "</{found}> closes <{expected}>.", "hint": "Close <{expected}> before </{found}>: tags nest, the last one opened closes first."},
397
414
  "bsx.duplicate_attribute": {"level": "error", "message": "<{component}> sets {key} twice.", "hint": "Keep one {key}; to choose between values, write one expression (c ? a : b)."},
@@ -440,7 +457,13 @@
440
457
  "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."},
441
458
  "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."},
442
459
  "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)."},
443
- "local.like": {"level": "error", "message": "local {name!r}: Local.like names {action!r}, which {problem}."},
460
+ "local.like": {"level": "error", "message": "local {name!r}: like={like!r} {problem}.", "hint": "Write like=\"self.<action>.<arg>\" or like=\"deps.<key>.<action>.<arg>\"."},
461
+ "local.position": {"level": "error", "message": "local {name!r} {problem}.", "hint": "Declare a local first among its parent's children, inside an element that takes children."},
462
+ "local.attribute": {"level": "error", "message": "local {name!r}: {key} {problem}.", "hint": "Every attribute of a local but name is a literal: default={{3}}, persist, kind=\"INT\"."},
463
+ "local.persist_id": {"level": "warning", "message": "local {name!r} persists inside a foreach without key: its kept value follows the item's position, not the item.", "hint": "Give the foreach a key={{...}}."},
464
+ "query.position": {"level": "error", "message": "<{component}> {name!r} is declared at {at}: queries and subscriptions are children of <Blok>.", "hint": "Move it to the top of the <Blok>."},
465
+ "query.duplicate": {"level": "error", "message": "{what} {name!r} is declared twice ({first} and {second})."},
466
+ "query.declaration": {"level": "error", "message": "<{component}> {problem}."},
444
467
  "local.bind_kind": {"level": "error", "message": "{key} of <{component}> writes a {prop_kind}, but {path} is a {kind} local (a {prop_kind} control writes {kinds}).", "hint": "Bind a local of a kind the control writes, or leave the local's kind out so the control sets it."},
445
468
  "local.arg_kind": {"level": "error", "message": "{call}: {argument} takes a {port_kind}, but {path} is a {kind} local.", "hint": "Pass a local of the argument's kind, or leave the local's kind out so the argument sets it."},
446
469
  "local.unused_persist": {"level": "warning", "message": "local {name!r} persists, but no control binds it.", "hint": "Bind a control to it, or drop persist."},
@@ -462,10 +485,13 @@
462
485
  "props.literal_type": {"level": "error", "message": "<{component}> {key}={value!r} is a string, but {key} takes a {kind}; write {hint}.", "hint": "Write the value as an expression in braces: {key}={{...}}."},
463
486
  "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}})."},
464
487
  "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."},
465
- "context.root": {"level": "error", "message": "The root of a {context} blok is <{root}>, not <{component}>.", "hint": "Make <{root}> the root and put <{component}> inside it."},
466
- "context.root_unknown": {"level": "error", "message": "A blok's root names its context ({roots}), not <{component}>.", "hint": "Make the root one of {roots} and put <{component}> inside it."},
488
+ "blok.root": {"level": "error", "message": "A blok is one <Blok kind=... context=...> element, not <{component}>.", "hint": "Wrap it: <Blok kind=\"agent\" context=\"panel\">...</Blok>."},
489
+ "blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign\" and context=\"panel|scene|logo\" as literals."},
490
+ "blok.content": {"level": "error", "message": "A {context} blok holds {expected} beside its declarations, not {found}.", "hint": "Put everything inside one {expected}."},
467
491
  "context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
468
- "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": "Declare it with the action: @app.workflow(assign_bloks=[...])."},
492
+ "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."},
493
+ "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."},
494
+ "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=[...]."},
469
495
  "logo.complexity": {"level": "error", "message": "{detail}"},
470
496
  "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."},
471
497
  "catalog.children": {"level": "warning", "message": "<{component}> takes no children.", "hint": "Close <{component}> without children (<{component} ... />), or put them beside it."},
@@ -476,7 +502,7 @@
476
502
  "catalog.asset": {"level": "warning", "message": "{key} of <{component}> names an asset as <agent>.assets.<name>.", "hint": "Write {key}={{self.assets.<name>}} with an asset the app registered."},
477
503
  "catalog.target": {"level": "error", "message": "<{component}> is of {catalog}, and this blok is written for {target}.", "hint": "Name the catalog it is written for (catalog=\"{catalog}\"), or use what {target} draws."},
478
504
  "catalog.unknown": {"level": "warning", "message": "The catalog {catalog!r} is not known here ({catalogs}), so what it adds to the base catalog is not checked.", "hint": "Register the catalog with the tooling, or check the address."},
479
- "catalog.kind": {"level": "error", "message": "<{component}> belongs to {kinds} bloks, not to a{n} {kind} blok.", "hint": "Declare it with the action: @app.workflow(bloks=[...]) for a run, assign_bloks=[...] for starting one."},
505
+ "catalog.kind": {"level": "error", "message": "<{component}> belongs to {kinds} bloks, not to a{n} {kind} blok.", "hint": "Declare it with the action, in bloks=[...]: <Blok kind=\"action\"> for a run, <Blok kind=\"assign\"> for starting one."},
480
506
  "catalog.context": {"level": "warning", "message": "<{component}> needs the {service} service where it is drawn; without it a notice shows in its place."},
481
507
  "part.conditional": {"level": "warning", "message": "<{component}> is inside <{inside}>: placing it anywhere claims it, so the host draws none of its own even while this one does not show.", "hint": "Place <{component}> outside <{inside}>, or hide what is around it instead."},
482
508
  "chrome.no_ask": {"level": "warning", "message": "chrome=\"none\" leaves the run's asks to the blok, and it places no <ask />: an ask can then only be answered elsewhere.", "hint": "Place <ask /> where the run's questions should show, or answer task.ask with task.answer(values: ...)."},
@@ -486,7 +512,7 @@
486
512
  "manifest.catalog": {"level": "error", "message": "Catalog {catalog!r} is neither the address a catalog is published at (https://arkitekt.live/catalogs/orkestrator/v1) nor the name of one registered in the organization."},
487
513
  "manifest.duplicate": {"level": "error", "message": "{what}: {key!r} is declared twice."},
488
514
  "manifest.name": {"level": "error", "message": "{what}: {key!r} is not a name."},
489
- "manifest.action_logo": {"level": "error", "message": "An action logo reads only the task it is drawn against: no locals, queries, subscriptions or dependencies."},
515
+ "manifest.action_logo": {"level": "error", "message": "An action logo reads only the task it is drawn against: no dependencies."},
490
516
  "manifest.demo": {"level": "error", "message": "demo.deps names {keys}, which are not dependencies of the blok."}
491
517
  }
492
518
  }
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "vocab": 2,
3
- "minor": 1,
3
+ "minor": 2,
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": {
@@ -35,47 +35,62 @@ export default {
35
35
  "description": "Declared by an app for its own agent (app.blok).",
36
36
  "roots": ["self", "args", "queries", "subscriptions", "viewer", "then"],
37
37
  "locals": true,
38
- "contexts": ["HTML", "SCENE", "LOGO"]
38
+ "contexts": ["PANEL", "SCENE", "LOGO"]
39
39
  },
40
40
  "custom": {
41
41
  "description": "Built by a user and materialized onto agents.",
42
42
  "roots": ["deps", "args", "queries", "subscriptions", "viewer", "then"],
43
43
  "locals": true,
44
- "contexts": ["HTML", "SCENE"]
44
+ "contexts": ["PANEL", "SCENE"]
45
45
  },
46
46
  "task": {
47
47
  "description": "A task's ask or inform blok; its dependencies are the sending task's, mapped.",
48
48
  "roots": ["self", "deps", "args", "task", "queries", "subscriptions", "viewer", "then"],
49
49
  "locals": true,
50
- "contexts": ["HTML"]
50
+ "contexts": ["PANEL"]
51
51
  },
52
52
  "action": {
53
- "description": "An action's own blok, declared inline with the action (ActionBlok); its dependencies are the action's.",
53
+ "description": "An action's own blok, declared with the action (bloks=); its dependencies are the action's. In the logo context it is the action's logo, drawn against the task the viewer last ran of it (null until then): it reads only task and declares nothing.",
54
54
  "roots": ["self", "deps", "args", "task", "queries", "subscriptions", "viewer", "then"],
55
55
  "locals": true,
56
- "contexts": ["HTML", "SCENE"]
56
+ "contexts": ["PANEL", "SCENE", "LOGO"],
57
+ "in": {"LOGO": {"roots": ["task"], "locals": false}}
57
58
  },
58
59
  "assign": {
59
- "description": "An action's own blok for starting a run of it (assign_bloks): shown before there is a task, with the arguments being filled in as args and the agents a run would get as deps.",
60
+ "description": "An action's own blok for starting a run of it (bloks=, kind assign): shown before there is a task, with the arguments being filled in as args and the agents a run would get as deps.",
60
61
  "roots": ["self", "deps", "args", "assign", "queries", "subscriptions", "viewer"],
61
62
  "locals": true,
62
- "contexts": ["HTML", "SCENE"]
63
- },
64
- "action_logo": {
65
- "description": "An action's logo, drawn against the task the viewer last ran of it (null until then).",
66
- "roots": ["task"],
67
- "locals": false,
68
- "contexts": ["LOGO"]
63
+ "contexts": ["PANEL", "SCENE"]
69
64
  }
70
65
  },
71
66
  "contexts": {
72
- "HTML": {"text": true, "description": "Panels, dashboards and popouts."},
67
+ "PANEL": {"text": true, "description": "Panels, dashboards and popouts: a flat rectangle the host lays out."},
73
68
  "SCENE": {"text": false, "description": "A 3D view: a Scene, or an action's Space, which places the run's dependencies in a room whose layout is shared."},
74
- "LOGO": {"text": false, "description": "An SVG drawing in the viewer's palette: an agent's logo, or an action's (an ACTION_LOGO blok is drawn in LOGO)."}
69
+ "LOGO": {"text": false, "description": "An SVG drawing in the viewer's palette: an agent's logo, or an action's (kind action), which paints with the palette's pens only."}
75
70
  },
76
- "blok_roots": {
77
- "description": "A blok's root component names its context: every blok starts with one of these, and nothing else declares the context.",
78
- "roots": {"Html": "HTML", "Scene": "SCENE", "Space": "SCENE", "AgentLogo": "LOGO", "ActionLogo": "ACTION_LOGO"}
71
+ "blok": {
72
+ "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
+ "component": "Blok",
74
+ "attributes": {
75
+ "kind": "Required: agent, custom, task, action or assign (a row of kinds).",
76
+ "context": "Required: panel, scene or logo.",
77
+ "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
+ "chrome": "\"none\": the host draws none of its own interface around the blok (panel and scene only)."
79
+ },
80
+ "contexts": {"panel": "PANEL", "scene": "SCENE", "logo": "LOGO"},
81
+ "content": {
82
+ "description": "Per context, the one element a blok holds besides its declarations; a panel holds any elements.",
83
+ "SCENE": ["Scene", "Space"],
84
+ "LOGO": ["Logo"]
85
+ },
86
+ "chrome": ["PANEL", "SCENE"],
87
+ "declarations": {
88
+ "description": "What a blok owns, declared in its tree. Each is stored as a node of its own and draws nothing.",
89
+ "local": "<local name=\"x\" default={...} persist kind=... />: a local (see locals). It comes before every other child of its parent and is in scope in its parent's subtree only; inside a foreach there is one per item. Every attribute but name is a literal: a port field (kind, identifier, nullable, choices, children, label, description, default, ...), persist, or like=\"self.<action>.<arg>\" / like=\"deps.<key>.<action>.<arg>\" (the port of that argument, resolved where the blok is mounted).",
90
+ "query": "<query name=\"x\" service=\"mikro\" document=\"query (...) {...}\" poll={5} more=\"items\"><var key=\"k\" value={...} /></query>: a declared read, queries.<name>. A child of <Blok>, before its content.",
91
+ "subscription": "<subscription name=\"x\" service=\"mikro\" document=\"subscription (...) {...}\" keep={10} history=\"q\"><var key=\"k\" value={...} /></subscription>: a declared stream, subscriptions.<name>. A child of <Blok>, before its content.",
92
+ "var": "<var key=\"k\" value={expression or literal} />: one variable of a query or subscription; an expression over args, blok-level locals and agents."
93
+ }
79
94
  },
80
95
  "records": {
81
96
  "task": {
@@ -324,10 +339,12 @@ export default {
324
339
  "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."
325
340
  },
326
341
  "locals": {
327
- "description": "Blok-level form state that feeds a call: a local is an arg port (key, kind, identifier, nullable, default, children, choices, validators, description, ...) plus persist, written only through `bind` on controls, read bare. persist remembers the last input on this device. Its kind is a port kind or ANY; left out on the wire it is inferred (kind_inference) and the stored local always carries one.",
342
+ "description": "Form state that feeds a call, declared in the tree as <local name=... />: a local is an arg port (key, kind, identifier, nullable, default, children, choices, validators, description, ...) plus persist, written only through `bind` on controls, read bare. persist remembers the last input on this device. Its kind is a port kind or ANY; left out it is inferred (kind_inference).",
328
343
  "fields": ["persist"],
344
+ "node": {"component": "local", "name": "name", "like": "like", "persist": "persist"},
345
+ "scope": "A local is in scope in its parent's subtree: its siblings, their children, and nothing outside its parent. It is the first of its parent's children (only other locals before it), never a child of a component that takes no children. Inside a foreach there is one value per item (by the item's runtime id); it lives as long as the blok is open, an if's branch closing and reopening included. A kept (persist) value is kept by the local's runtime id: an explicit id keeps it across edits of the tree. A local never shadows a name in scope (another local, a let, an into name) nor a reserved root.",
329
346
  "any": "ANY is a local's kind only (no action port is ever ANY): an untyped value. It is never an error and gets no warning; it skips the bind_kinds and arg_kinds checks and a path below it is taken as written. A renderer treats it as an untyped value.",
330
- "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "The SDK's Local[T]() / Local(type=T) and Local.like(action, arg) come before rule 1. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
347
+ "kind_inference": ["A given kind (ANY included) is kept; only a left-out kind is inferred, by the first rule that gives one:", "1. the default: a bool BOOL, an integer INT, any other number FLOAT, a string STRING; a non-empty list of one scalar kind LIST of it, a non-empty object of one scalar kind DICT of it (the item port keyed ...); null, [], {} and mixed items tell nothing;", "2. the port of the task argument the local is passed to whole (an argument whose value is exactly the local's path), at the first such call in tree order whose arg port is known and makes a valid local: its kind, identifier, nullable, choices, reference_unit, proposed_units, dimension and children (from a demand's arg match: kind, identifier, nullable and children, every child with a kind);", "3. the bind kind of the first control bound to the local whole, when it is STRING, INT, FLOAT or BOOL (LIST, DICT and ANY controls tell too little);", "4. else ANY.", "A given kind and like= come before rule 1. Only uses inside the local's scope (its parent's subtree) count. Tree order is the walk order: nodes depth first, each node's props in order, a call's arguments in order. Every field the local sets (choices, nullable, widget, identifier, children, description, ...) wins over the inferred type, which only fills what it leaves out; a candidate whose merge is no valid port is skipped. The other call sites and binds are then checked against the kind found (local.arg_kind, local.bind_kind). A left-out kind stays distinguishable from a given ANY until inference ran (no default filled in at deserialization; null is left out)."],
331
348
  "bind": "bind={<local>} or bind={<local>.<field>...}: the control writes the local; nothing else does. The catalog's kind of the bind prop is what the control writes: the local (or the field of it bound) must be a port kind bind_kinds lists for it.",
332
349
  "bind_kinds": {"description": "Per catalog kind of a bind prop, the port kinds of the locals it may write. A kind not listed (ANY) writes any local.", "STRING": ["STRING", "ENUM", "DATE"], "FLOAT": ["FLOAT", "INT", "QUANTITY"], "INT": ["INT"], "BOOL": ["BOOL"], "LIST": ["LIST"], "DICT": ["DICT", "MODEL"]},
333
350
  "arg_kinds": {"description": "Per port kind of a local passed whole as a task call's argument, the kinds of the action's arg port that take it, where the action is known (agent self.<action> demands, an action's dependencies). STRUCTURE also needs the same identifier. An ANY local is not checked.", "STRING": ["STRING"], "INT": ["INT", "FLOAT"], "FLOAT": ["FLOAT"], "BOOL": ["BOOL"], "ENUM": ["ENUM", "STRING"], "DATE": ["DATE", "STRING"], "QUANTITY": ["QUANTITY", "FLOAT"], "LIST": ["LIST"], "DICT": ["DICT"], "MODEL": ["MODEL", "DICT"], "STRUCTURE": ["STRUCTURE"]}
@@ -370,9 +387,9 @@ export default {
370
387
  "logo_path_data_props": ["d", "points"]
371
388
  },
372
389
  "catalogs": {
373
- "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (HTML, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
374
- "base": "https://arkitekt.live/catalogs/base/v3",
375
- "bundled": {"https://arkitekt.live/catalogs/base/v3": "catalogs/base@3.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
390
+ "description": "A catalog is a versioned set of components. The base catalog is what every renderer draws, whole, in the contexts it draws (PANEL, SCENE, LOGO): a blok written for it runs everywhere. An app catalog extends another (in the end the base) with what one frontend draws beyond it; it is that frontend's to publish. A catalog is named by the address it is published at (its id); a blok names the one catalog it is written for (catalog), the base when it names none, and may record the minor it needs (catalog_minor). A version only ever gains components and props: each says the minor that added it (since), so a blok valid at v1.2 stays valid. A renderer reports the catalogs and minors it speaks; what it lacks it draws as a placeholder, and reports. A catalog never redefines a component of the one it extends. Nobody's server fetches a catalog: it holds what a frontend registered under the id, and an author's tooling resolves an id from what ships with it, from its cache, or by fetching it.",
391
+ "base": "https://arkitekt.live/catalogs/base/v4",
392
+ "bundled": {"https://arkitekt.live/catalogs/base/v4": "catalogs/base@4.json", "https://arkitekt.live/catalogs/orkestrator/v1": "catalogs/orkestrator@1.json"},
376
393
  "id": "^https://[^\\s/]+(/[^\\s/]+)*/v[0-9]+$",
377
394
  "name": "^[A-Za-z_][A-Za-z0-9_.-]*$",
378
395
  "host_parts": {
@@ -390,8 +407,8 @@ export default {
390
407
  "diagnostics": {
391
408
  "description": "One table of stable codes, the same in Python, Rust and TypeScript. level: error refuses the blok, warning is reported; runtime: true marks a code no checker raises, the renderer's error code of a record (deps.unbound). Messages are str.format templates; parity compares codes, never text.",
392
409
  "bsx.syntax": {"level": "error", "message": "{detail}", "hint": "Fix the markup at the line and column given; every attribute is name=\"text\" or name={{expression}}."},
393
- "bsx.empty": {"level": "error", "message": "A blok has one root element; this source has none.", "hint": "Write one root element, the one the blok's context names (<Html> for an html blok)."},
394
- "bsx.multiple_roots": {"level": "error", "message": "A blok has one root element; found another after it: <{component}>.", "hint": "Wrap everything in the one root element (<Html>...</Html>); siblings go inside it."},
410
+ "bsx.empty": {"level": "error", "message": "A blok has one root element; this source has none.", "hint": "Write one root element: <Blok kind=\"...\" context=\"...\">."},
411
+ "bsx.multiple_roots": {"level": "error", "message": "A blok has one root element; found another after it: <{component}>.", "hint": "Wrap everything in the one root element (<Blok ...>...</Blok>); siblings go inside it."},
395
412
  "bsx.unclosed": {"level": "error", "message": "<{component}> is never closed.", "hint": "Close it with </{component}>, or write it self-closing as <{component} ... />."},
396
413
  "bsx.mismatched_tag": {"level": "error", "message": "</{found}> closes <{expected}>.", "hint": "Close <{expected}> before </{found}>: tags nest, the last one opened closes first."},
397
414
  "bsx.duplicate_attribute": {"level": "error", "message": "<{component}> sets {key} twice.", "hint": "Keep one {key}; to choose between values, write one expression (c ? a : b)."},
@@ -440,7 +457,13 @@ export default {
440
457
  "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."},
441
458
  "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."},
442
459
  "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)."},
443
- "local.like": {"level": "error", "message": "local {name!r}: Local.like names {action!r}, which {problem}."},
460
+ "local.like": {"level": "error", "message": "local {name!r}: like={like!r} {problem}.", "hint": "Write like=\"self.<action>.<arg>\" or like=\"deps.<key>.<action>.<arg>\"."},
461
+ "local.position": {"level": "error", "message": "local {name!r} {problem}.", "hint": "Declare a local first among its parent's children, inside an element that takes children."},
462
+ "local.attribute": {"level": "error", "message": "local {name!r}: {key} {problem}.", "hint": "Every attribute of a local but name is a literal: default={{3}}, persist, kind=\"INT\"."},
463
+ "local.persist_id": {"level": "warning", "message": "local {name!r} persists inside a foreach without key: its kept value follows the item's position, not the item.", "hint": "Give the foreach a key={{...}}."},
464
+ "query.position": {"level": "error", "message": "<{component}> {name!r} is declared at {at}: queries and subscriptions are children of <Blok>.", "hint": "Move it to the top of the <Blok>."},
465
+ "query.duplicate": {"level": "error", "message": "{what} {name!r} is declared twice ({first} and {second})."},
466
+ "query.declaration": {"level": "error", "message": "<{component}> {problem}."},
444
467
  "local.bind_kind": {"level": "error", "message": "{key} of <{component}> writes a {prop_kind}, but {path} is a {kind} local (a {prop_kind} control writes {kinds}).", "hint": "Bind a local of a kind the control writes, or leave the local's kind out so the control sets it."},
445
468
  "local.arg_kind": {"level": "error", "message": "{call}: {argument} takes a {port_kind}, but {path} is a {kind} local.", "hint": "Pass a local of the argument's kind, or leave the local's kind out so the argument sets it."},
446
469
  "local.unused_persist": {"level": "warning", "message": "local {name!r} persists, but no control binds it.", "hint": "Bind a control to it, or drop persist."},
@@ -462,10 +485,13 @@ export default {
462
485
  "props.literal_type": {"level": "error", "message": "<{component}> {key}={value!r} is a string, but {key} takes a {kind}; write {hint}.", "hint": "Write the value as an expression in braces: {key}={{...}}."},
463
486
  "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}})."},
464
487
  "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."},
465
- "context.root": {"level": "error", "message": "The root of a {context} blok is <{root}>, not <{component}>.", "hint": "Make <{root}> the root and put <{component}> inside it."},
466
- "context.root_unknown": {"level": "error", "message": "A blok's root names its context ({roots}), not <{component}>.", "hint": "Make the root one of {roots} and put <{component}> inside it."},
488
+ "blok.root": {"level": "error", "message": "A blok is one <Blok kind=... context=...> element, not <{component}>.", "hint": "Wrap it: <Blok kind=\"agent\" context=\"panel\">...</Blok>."},
489
+ "blok.attribute": {"level": "error", "message": "<Blok> {problem}.", "hint": "Write kind=\"agent|custom|task|action|assign\" and context=\"panel|scene|logo\" as literals."},
490
+ "blok.content": {"level": "error", "message": "A {context} blok holds {expected} beside its declarations, not {found}.", "hint": "Put everything inside one {expected}."},
467
491
  "context.kind": {"level": "error", "message": "A{n} {kind} blok is drawn in {contexts}, not {context}."},
468
- "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": "Declare it with the action: @app.workflow(assign_bloks=[...])."},
492
+ "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."},
493
+ "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."},
494
+ "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=[...]."},
469
495
  "logo.complexity": {"level": "error", "message": "{detail}"},
470
496
  "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."},
471
497
  "catalog.children": {"level": "warning", "message": "<{component}> takes no children.", "hint": "Close <{component}> without children (<{component} ... />), or put them beside it."},
@@ -476,7 +502,7 @@ export default {
476
502
  "catalog.asset": {"level": "warning", "message": "{key} of <{component}> names an asset as <agent>.assets.<name>.", "hint": "Write {key}={{self.assets.<name>}} with an asset the app registered."},
477
503
  "catalog.target": {"level": "error", "message": "<{component}> is of {catalog}, and this blok is written for {target}.", "hint": "Name the catalog it is written for (catalog=\"{catalog}\"), or use what {target} draws."},
478
504
  "catalog.unknown": {"level": "warning", "message": "The catalog {catalog!r} is not known here ({catalogs}), so what it adds to the base catalog is not checked.", "hint": "Register the catalog with the tooling, or check the address."},
479
- "catalog.kind": {"level": "error", "message": "<{component}> belongs to {kinds} bloks, not to a{n} {kind} blok.", "hint": "Declare it with the action: @app.workflow(bloks=[...]) for a run, assign_bloks=[...] for starting one."},
505
+ "catalog.kind": {"level": "error", "message": "<{component}> belongs to {kinds} bloks, not to a{n} {kind} blok.", "hint": "Declare it with the action, in bloks=[...]: <Blok kind=\"action\"> for a run, <Blok kind=\"assign\"> for starting one."},
480
506
  "catalog.context": {"level": "warning", "message": "<{component}> needs the {service} service where it is drawn; without it a notice shows in its place."},
481
507
  "part.conditional": {"level": "warning", "message": "<{component}> is inside <{inside}>: placing it anywhere claims it, so the host draws none of its own even while this one does not show.", "hint": "Place <{component}> outside <{inside}>, or hide what is around it instead."},
482
508
  "chrome.no_ask": {"level": "warning", "message": "chrome=\"none\" leaves the run's asks to the blok, and it places no <ask />: an ask can then only be answered elsewhere.", "hint": "Place <ask /> where the run's questions should show, or answer task.ask with task.answer(values: ...)."},
@@ -486,7 +512,7 @@ export default {
486
512
  "manifest.catalog": {"level": "error", "message": "Catalog {catalog!r} is neither the address a catalog is published at (https://arkitekt.live/catalogs/orkestrator/v1) nor the name of one registered in the organization."},
487
513
  "manifest.duplicate": {"level": "error", "message": "{what}: {key!r} is declared twice."},
488
514
  "manifest.name": {"level": "error", "message": "{what}: {key!r} is not a name."},
489
- "manifest.action_logo": {"level": "error", "message": "An action logo reads only the task it is drawn against: no locals, queries, subscriptions or dependencies."},
515
+ "manifest.action_logo": {"level": "error", "message": "An action logo reads only the task it is drawn against: no dependencies."},
490
516
  "manifest.demo": {"level": "error", "message": "demo.deps names {keys}, which are not dependencies of the blok."}
491
517
  }
492
518
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkitektio/bsx",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "The BSX language, the blok spec, runtime and React renderer: one copy for every Arkitekt frontend.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,9 +1,9 @@
1
1
  import type {BlokComponentNode} from '../renderer/runtime/types';
2
- import {defaultBlokView, type BlokView} from '../spec/catalogs';
2
+ import {type BlokView} from '../spec/catalogs';
3
3
  import {diagnosticHint, type BlokFinding} from '../spec/vocabulary';
4
4
  import {parseBsxSafe, type BsxSourceMap} from './parse';
5
- import {resolveBlokScope} from './infer';
6
- import {checkBlokTree, type BlokCheckScope, type ResolvedBlokScope} from './references';
5
+ import {resolveLocals, type ResolvedLocal} from './infer';
6
+ import {checkBlokTree, unmountedBlokScope, viewForTree, type BlokCheckScope} from './references';
7
7
  import type {BsxRange} from './source';
8
8
 
9
9
  export type BsxMarker = {message: string; range: BsxRange; severity: 'error' | 'warning'; code?: string};
@@ -16,8 +16,8 @@ export type BsxAnalysis = {
16
16
  /** The validator's findings (none when the text does not parse). */
17
17
  findings: BlokFinding[];
18
18
  markers: BsxMarker[];
19
- /** The scope as the tree resolves it (each local's kind; dependencies stay as declared); null when the text does not parse. */
20
- resolved: ResolvedBlokScope | null;
19
+ /** Each `<local>` of the tree with its kind resolved, by node id; null when the text does not parse. */
20
+ resolved: ReadonlyMap<string, ResolvedLocal> | null;
21
21
  };
22
22
 
23
23
  /** Where a finding about `nodeId` (and `propKey`) is in the source; `fallback` when the source map has no such node. */
@@ -32,15 +32,16 @@ export const rangeForFinding = (sources: BsxSourceMap, nodeId: string | undefine
32
32
  /**
33
33
  * Everything the editor marks in a blok's source: where it does not parse
34
34
  * (the parser's first refusal, with its code); else every finding of the v2
35
- * validator (`checkBlokTree`) against what the blok declares, errors and
36
- * warnings, each at the node and prop it is about.
35
+ * validator (`checkBlokTree`), mounted as `scope` says (unmounted when it
36
+ * says nothing), errors and warnings, each at the node and prop it is about.
37
+ * Without a view, the one of the catalog its `<Blok catalog>` names.
37
38
  */
38
39
  /** A marker's text: the message, then how to fix it on a line of its own. */
39
40
  const withHint = (message: string, hint: string | null): string => (hint ? `${message}\n${hint}` : message);
40
41
 
41
- export const analyzeBsx = (source: string, options: {scope: BlokCheckScope; view?: BlokView}): BsxAnalysis => {
42
- const view = options.view ?? defaultBlokView();
43
- const parsed = parseBsxSafe(source, view);
42
+ export const analyzeBsx = (source: string, options: {scope?: BlokCheckScope | null; view?: BlokView} = {}): BsxAnalysis => {
43
+ const scope = options.scope ?? unmountedBlokScope();
44
+ const parsed = parseBsxSafe(source, options.view);
44
45
  if (!parsed.ok) {
45
46
  return {
46
47
  tree: null,
@@ -51,8 +52,9 @@ export const analyzeBsx = (source: string, options: {scope: BlokCheckScope; view
51
52
  };
52
53
  }
53
54
  const {tree, sources} = parsed;
55
+ const view = options.view ?? viewForTree(tree);
54
56
  const whole = sources.get(tree.id)?.tagRange ?? {start: 0, end: 1};
55
- const findings = checkBlokTree(tree, options.scope, view);
57
+ const findings = checkBlokTree(tree, scope, view);
56
58
  const markers = findings.map(
57
59
  (found): BsxMarker => ({
58
60
  message: withHint(found.message, found.hint ?? null),
@@ -61,5 +63,5 @@ export const analyzeBsx = (source: string, options: {scope: BlokCheckScope; view
61
63
  code: found.code,
62
64
  }),
63
65
  );
64
- return {tree, sources, findings, markers, resolved: resolveBlokScope(tree, options.scope, view)};
66
+ return {tree, sources, findings, markers, resolved: resolveLocals(tree, scope.dependencies, view)};
65
67
  };
@@ -81,10 +81,10 @@ describe('positions', () => {
81
81
  });
82
82
 
83
83
  it('keeps where every node and prop is', () => {
84
- const {sources} = parseBsx('<Html><Card>\n <Button label="Go" />\n</Card></Html>');
85
- const button = sources.get('Html[0]/Card[0]/Button[0]');
86
- expect(button?.tagRange).toEqual({start: 16, end: 22});
87
- expect(button?.props.get('label')?.valueRange).toEqual({start: 30, end: 32});
84
+ const {sources} = parseBsx('<Blok kind="agent" context="panel"><Card>\n <Button label="Go" />\n</Card></Blok>');
85
+ const button = sources.get('Blok[0]/Card[0]/Button[0]');
86
+ expect(button?.tagRange).toEqual({start: 45, end: 51});
87
+ expect(button?.props.get('label')?.valueRange).toEqual({start: 59, end: 61});
88
88
  });
89
89
 
90
90
  it('refuses a source over 256 KiB of UTF-8', () => {