@almadar/std 6.4.1 → 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 (40) hide show
  1. package/behaviors/registry/atoms/std-search.orb +2 -2
  2. package/behaviors/registry/atoms/std-selection.orb +2 -2
  3. package/behaviors/registry/atoms/std-sort.orb +2 -2
  4. package/behaviors/registry/atoms/std-sprite.orb +2 -2
  5. package/dist/behaviors/registry/atoms/std-search.orb +2 -2
  6. package/dist/behaviors/registry/atoms/std-selection.orb +2 -2
  7. package/dist/behaviors/registry/atoms/std-sort.orb +2 -2
  8. package/dist/behaviors/registry/atoms/std-sprite.orb +2 -2
  9. package/dist/index.d.ts +4 -3
  10. package/dist/index.js +559 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/modules/agent.d.ts +1 -1
  13. package/dist/modules/array.d.ts +1 -1
  14. package/dist/modules/async.d.ts +1 -1
  15. package/dist/modules/composition.d.ts +1 -1
  16. package/dist/modules/contract.d.ts +1 -1
  17. package/dist/modules/core.d.ts +27 -0
  18. package/dist/modules/core.js +486 -0
  19. package/dist/modules/core.js.map +1 -0
  20. package/dist/modules/data.d.ts +1 -1
  21. package/dist/modules/format.d.ts +1 -1
  22. package/dist/modules/graph.d.ts +1 -1
  23. package/dist/modules/index.d.ts +2 -1
  24. package/dist/modules/index.js +484 -1
  25. package/dist/modules/index.js.map +1 -1
  26. package/dist/modules/math.d.ts +1 -1
  27. package/dist/modules/nn.d.ts +1 -1
  28. package/dist/modules/object.d.ts +1 -1
  29. package/dist/modules/os.d.ts +1 -1
  30. package/dist/modules/prob.d.ts +1 -1
  31. package/dist/modules/str.d.ts +1 -1
  32. package/dist/modules/tensor.d.ts +1 -1
  33. package/dist/modules/time.d.ts +1 -1
  34. package/dist/modules/train.d.ts +1 -1
  35. package/dist/modules/validate.d.ts +1 -1
  36. package/dist/registry.d.ts +7 -3
  37. package/dist/registry.js +485 -1
  38. package/dist/registry.js.map +1 -1
  39. package/dist/{types-hu1LavLs.d.ts → types-DUr71Cgy.d.ts} +62 -3
  40. package/package.json +2 -3
@@ -1,3 +1,486 @@
1
+ // modules/core.ts
2
+ var NUMBER = "number";
3
+ var BOOLEAN = "boolean";
4
+ var STRING = "string";
5
+ var ANY = "any";
6
+ var SEXPR = { kind: "sexpr" };
7
+ var BINDING = { kind: "binding" };
8
+ var ENTITY_REF = { kind: "entityRef" };
9
+ var EVENT_KEY = { kind: "eventKey" };
10
+ var UI_SLOT = { kind: "uiSlot" };
11
+ var PATTERN_TYPE = { kind: "patternType" };
12
+ var PERSIST_ACTION = {
13
+ kind: "union",
14
+ of: [
15
+ { kind: "literal", value: "create" },
16
+ { kind: "literal", value: "update" },
17
+ { kind: "literal", value: "delete" },
18
+ { kind: "literal", value: "clear" },
19
+ { kind: "literal", value: "batch" }
20
+ ]
21
+ };
22
+ var SET_OPERATION = {
23
+ kind: "union",
24
+ of: [
25
+ { kind: "literal", value: "increment" },
26
+ { kind: "literal", value: "decrement" },
27
+ { kind: "literal", value: "multiply" },
28
+ { kind: "literal", value: "append" },
29
+ { kind: "literal", value: "remove" }
30
+ ]
31
+ };
32
+ var NOTIFY_CHANNEL = {
33
+ kind: "union",
34
+ of: [
35
+ { kind: "literal", value: "email" },
36
+ { kind: "literal", value: "push" },
37
+ { kind: "literal", value: "sms" },
38
+ { kind: "literal", value: "in_app" }
39
+ ]
40
+ };
41
+ var CORE_OPERATORS = {
42
+ // --- arithmetic primitives --------------------------------------------------
43
+ "+": {
44
+ module: "core",
45
+ category: "arithmetic",
46
+ minArity: 2,
47
+ maxArity: null,
48
+ description: "Add numbers",
49
+ hasSideEffects: false,
50
+ returnType: "number",
51
+ params: [{ name: "...nums", type: NUMBER, description: "Numbers to sum" }],
52
+ example: '["+", 1, 2, 3] // => 6'
53
+ },
54
+ "-": {
55
+ module: "core",
56
+ category: "arithmetic",
57
+ minArity: 1,
58
+ maxArity: 2,
59
+ description: "Subtract or negate",
60
+ hasSideEffects: false,
61
+ returnType: "number",
62
+ params: [
63
+ { name: "a", type: NUMBER, description: "Left operand or value to negate" },
64
+ { name: "b", type: NUMBER, description: "Right operand", optional: true }
65
+ ],
66
+ example: '["-", 5, 2] // => 3; ["-", 5] // => -5'
67
+ },
68
+ "*": {
69
+ module: "core",
70
+ category: "arithmetic",
71
+ minArity: 2,
72
+ maxArity: null,
73
+ description: "Multiply numbers",
74
+ hasSideEffects: false,
75
+ returnType: "number",
76
+ params: [{ name: "...nums", type: NUMBER, description: "Numbers to multiply" }],
77
+ example: '["*", 2, 3, 4] // => 24'
78
+ },
79
+ "/": {
80
+ module: "core",
81
+ category: "arithmetic",
82
+ minArity: 2,
83
+ maxArity: 2,
84
+ description: "Divide numbers",
85
+ hasSideEffects: false,
86
+ returnType: "number",
87
+ params: [
88
+ { name: "a", type: NUMBER, description: "Numerator" },
89
+ { name: "b", type: NUMBER, description: "Denominator" }
90
+ ],
91
+ example: '["/", 10, 2] // => 5'
92
+ },
93
+ "%": {
94
+ module: "core",
95
+ category: "arithmetic",
96
+ minArity: 2,
97
+ maxArity: 2,
98
+ description: "Modulo (remainder)",
99
+ hasSideEffects: false,
100
+ returnType: "number",
101
+ params: [
102
+ { name: "a", type: NUMBER, description: "Dividend" },
103
+ { name: "b", type: NUMBER, description: "Divisor" }
104
+ ],
105
+ example: '["%", 10, 3] // => 1'
106
+ },
107
+ // --- comparison -------------------------------------------------------------
108
+ "=": {
109
+ module: "core",
110
+ category: "comparison",
111
+ minArity: 2,
112
+ maxArity: 2,
113
+ description: "Equal to",
114
+ hasSideEffects: false,
115
+ returnType: "boolean",
116
+ params: [
117
+ { name: "a", type: ANY, description: "Left operand" },
118
+ { name: "b", type: ANY, description: "Right operand" }
119
+ ],
120
+ example: '["=", "@entity.status", "active"]'
121
+ },
122
+ "!=": {
123
+ module: "core",
124
+ category: "comparison",
125
+ minArity: 2,
126
+ maxArity: 2,
127
+ description: "Not equal to",
128
+ hasSideEffects: false,
129
+ returnType: "boolean",
130
+ params: [
131
+ { name: "a", type: ANY, description: "Left operand" },
132
+ { name: "b", type: ANY, description: "Right operand" }
133
+ ],
134
+ example: '["!=", "@entity.id", null]'
135
+ },
136
+ "<": {
137
+ module: "core",
138
+ category: "comparison",
139
+ minArity: 2,
140
+ maxArity: 2,
141
+ description: "Less than",
142
+ hasSideEffects: false,
143
+ returnType: "boolean",
144
+ params: [
145
+ { name: "a", type: NUMBER, description: "Left operand" },
146
+ { name: "b", type: NUMBER, description: "Right operand" }
147
+ ],
148
+ example: '["<", "@entity.health", 10]'
149
+ },
150
+ ">": {
151
+ module: "core",
152
+ category: "comparison",
153
+ minArity: 2,
154
+ maxArity: 2,
155
+ description: "Greater than",
156
+ hasSideEffects: false,
157
+ returnType: "boolean",
158
+ params: [
159
+ { name: "a", type: NUMBER, description: "Left operand" },
160
+ { name: "b", type: NUMBER, description: "Right operand" }
161
+ ],
162
+ example: '[">", "@entity.score", 0]'
163
+ },
164
+ "<=": {
165
+ module: "core",
166
+ category: "comparison",
167
+ minArity: 2,
168
+ maxArity: 2,
169
+ description: "Less than or equal",
170
+ hasSideEffects: false,
171
+ returnType: "boolean",
172
+ params: [
173
+ { name: "a", type: NUMBER, description: "Left operand" },
174
+ { name: "b", type: NUMBER, description: "Right operand" }
175
+ ],
176
+ example: '["<=", "@entity.count", 100]'
177
+ },
178
+ ">=": {
179
+ module: "core",
180
+ category: "comparison",
181
+ minArity: 2,
182
+ maxArity: 2,
183
+ description: "Greater than or equal",
184
+ hasSideEffects: false,
185
+ returnType: "boolean",
186
+ params: [
187
+ { name: "a", type: NUMBER, description: "Left operand" },
188
+ { name: "b", type: NUMBER, description: "Right operand" }
189
+ ],
190
+ example: '[">=", "@entity.age", 18]'
191
+ },
192
+ // --- logic ------------------------------------------------------------------
193
+ and: {
194
+ module: "core",
195
+ category: "logic",
196
+ minArity: 2,
197
+ maxArity: null,
198
+ description: "Logical AND",
199
+ hasSideEffects: false,
200
+ returnType: "boolean",
201
+ params: [{ name: "...conds", type: BOOLEAN, description: "Boolean expressions to AND" }],
202
+ example: '["and", ["=", "@entity.active", true], [">", "@entity.score", 0]]'
203
+ },
204
+ or: {
205
+ module: "core",
206
+ category: "logic",
207
+ minArity: 2,
208
+ maxArity: null,
209
+ description: "Logical OR",
210
+ hasSideEffects: false,
211
+ returnType: "boolean",
212
+ params: [{ name: "...conds", type: BOOLEAN, description: "Boolean expressions to OR" }],
213
+ example: '["or", ["=", "@entity.role", "admin"], ["=", "@entity.role", "owner"]]'
214
+ },
215
+ not: {
216
+ module: "core",
217
+ category: "logic",
218
+ minArity: 1,
219
+ maxArity: 1,
220
+ description: "Logical NOT",
221
+ hasSideEffects: false,
222
+ returnType: "boolean",
223
+ params: [{ name: "cond", type: BOOLEAN, description: "Boolean to negate" }],
224
+ example: '["not", "@entity.disabled"]'
225
+ },
226
+ if: {
227
+ module: "core",
228
+ category: "logic",
229
+ minArity: 3,
230
+ maxArity: 3,
231
+ description: "Conditional expression (ternary)",
232
+ hasSideEffects: false,
233
+ returnType: "any",
234
+ params: [
235
+ { name: "cond", type: BOOLEAN, description: "Condition to evaluate" },
236
+ { name: "then", type: ANY, description: "Value or effect if true" },
237
+ { name: "else", type: ANY, description: "Value or effect if false" }
238
+ ],
239
+ example: '["if", [">", "@entity.health", 0], "alive", "dead"]'
240
+ },
241
+ // --- control ----------------------------------------------------------------
242
+ let: {
243
+ module: "core",
244
+ category: "control",
245
+ minArity: 2,
246
+ maxArity: 2,
247
+ description: "Bind local variables for a body expression",
248
+ hasSideEffects: false,
249
+ returnType: "any",
250
+ params: [
251
+ {
252
+ name: "bindings",
253
+ type: { kind: "array", of: { kind: "array", of: ANY } },
254
+ description: "Array of [name, value] pairs"
255
+ },
256
+ { name: "body", type: SEXPR, description: "Expression or effect list using the bindings" }
257
+ ],
258
+ example: '["let", [["x", 10]], ["+", "x", 1]]'
259
+ },
260
+ do: {
261
+ module: "core",
262
+ category: "control",
263
+ minArity: 1,
264
+ maxArity: null,
265
+ description: "Sequential execution of multiple effects/expressions",
266
+ hasSideEffects: false,
267
+ returnType: "any",
268
+ params: [{ name: "...exprs", type: SEXPR, description: "Effects/expressions to run in order" }],
269
+ example: '["do", ["set", "@entity.x", 0], ["set", "@entity.y", 0]]'
270
+ },
271
+ when: {
272
+ module: "core",
273
+ category: "control",
274
+ minArity: 2,
275
+ maxArity: 2,
276
+ description: "Conditional effect without an else branch",
277
+ hasSideEffects: false,
278
+ returnType: "void",
279
+ params: [
280
+ { name: "cond", type: BOOLEAN, description: "Guard expression" },
281
+ { name: "effect", type: SEXPR, description: "Effect to run if cond is true" }
282
+ ],
283
+ example: '["when", [">", "@entity.health", 0], ["emit", "ALIVE"]]'
284
+ },
285
+ fn: {
286
+ module: "core",
287
+ category: "control",
288
+ minArity: 2,
289
+ maxArity: 2,
290
+ description: "Lambda expression (used for per-item renders and transforms)",
291
+ hasSideEffects: false,
292
+ returnType: "function",
293
+ acceptsLambda: true,
294
+ lambdaArgPosition: 1,
295
+ params: [
296
+ { name: "paramName", type: STRING, description: "Name of the parameter binding" },
297
+ { name: "body", type: SEXPR, description: "Expression evaluated per invocation" }
298
+ ],
299
+ example: '["fn", "item", { "type": "typography", "content": "@item.title" }]'
300
+ },
301
+ // --- effect -----------------------------------------------------------------
302
+ set: {
303
+ module: "core",
304
+ category: "effect",
305
+ minArity: 2,
306
+ maxArity: 2,
307
+ description: "Set a binding to a value",
308
+ hasSideEffects: true,
309
+ returnType: "void",
310
+ params: [
311
+ { name: "binding", type: BINDING, description: 'Target binding (e.g. "@entity.field")' },
312
+ { name: "value", type: ANY, description: "Value to assign (literal or expression)" }
313
+ ],
314
+ example: '["set", "@entity.health", 100]',
315
+ effect: {
316
+ kind: "set",
317
+ config: { operation: SET_OPERATION }
318
+ }
319
+ },
320
+ emit: {
321
+ module: "core",
322
+ category: "effect",
323
+ minArity: 1,
324
+ maxArity: 2,
325
+ description: "Emit an event onto the bus",
326
+ hasSideEffects: true,
327
+ returnType: "void",
328
+ params: [
329
+ { name: "event", type: EVENT_KEY, description: "Event key" },
330
+ { name: "payload", type: ENTITY_REF, description: "Optional payload", optional: true }
331
+ ],
332
+ example: '["emit", "PLAYER_DIED", { "playerId": "@entity.id" }]',
333
+ effect: {
334
+ kind: "emit",
335
+ produces: {
336
+ kind: "object",
337
+ fields: { event: EVENT_KEY, payload: ANY },
338
+ open: true
339
+ }
340
+ }
341
+ },
342
+ persist: {
343
+ module: "core",
344
+ category: "effect",
345
+ minArity: 2,
346
+ maxArity: 3,
347
+ description: "Create, update, delete, clear, or batch entity records",
348
+ hasSideEffects: true,
349
+ returnType: "void",
350
+ params: [
351
+ { name: "action", type: PERSIST_ACTION, description: "Persist action" },
352
+ { name: "entity", type: { kind: "entity" }, description: "Target entity name" },
353
+ { name: "data", type: ENTITY_REF, description: "Payload (create/update) or entity id (delete)", optional: true }
354
+ ],
355
+ example: '["persist", "create", "Task", { "title": "@payload.title" }]',
356
+ effect: { kind: "persist" }
357
+ },
358
+ navigate: {
359
+ module: "core",
360
+ category: "effect",
361
+ minArity: 1,
362
+ maxArity: 2,
363
+ description: "Navigate to a route",
364
+ hasSideEffects: true,
365
+ returnType: "void",
366
+ params: [
367
+ { name: "path", type: STRING, description: "Route path (supports :param placeholders)" },
368
+ {
369
+ name: "params",
370
+ type: { kind: "object", fields: {}, open: true },
371
+ description: "Optional route params",
372
+ optional: true
373
+ }
374
+ ],
375
+ example: '["navigate", "/tasks/:id", { "id": "@entity.id" }]',
376
+ effect: { kind: "navigate" }
377
+ },
378
+ notify: {
379
+ module: "core",
380
+ category: "effect",
381
+ minArity: 1,
382
+ maxArity: 2,
383
+ description: "Show a notification (in-app, email, push, sms)",
384
+ hasSideEffects: true,
385
+ returnType: "void",
386
+ params: [
387
+ { name: "channel", type: NOTIFY_CHANNEL, description: "Delivery channel" },
388
+ { name: "message", type: STRING, description: "Message body", optional: true }
389
+ ],
390
+ example: '["notify", "in_app", "Task created successfully"]',
391
+ effect: { kind: "notify" }
392
+ },
393
+ spawn: {
394
+ module: "core",
395
+ category: "effect",
396
+ minArity: 1,
397
+ maxArity: 2,
398
+ description: "Spawn a new entity instance (games)",
399
+ hasSideEffects: true,
400
+ returnType: "void",
401
+ params: [
402
+ { name: "entity", type: { kind: "entity" }, description: "Entity name to spawn" },
403
+ {
404
+ name: "initialState",
405
+ type: { kind: "object", fields: {}, open: true },
406
+ description: "Initial field values",
407
+ optional: true
408
+ }
409
+ ],
410
+ example: '["spawn", "Bullet", { "x": "@entity.x", "y": "@entity.y" }]',
411
+ effect: { kind: "spawn" }
412
+ },
413
+ despawn: {
414
+ module: "core",
415
+ category: "effect",
416
+ minArity: 0,
417
+ maxArity: 1,
418
+ description: "Despawn an entity instance (games)",
419
+ hasSideEffects: true,
420
+ returnType: "void",
421
+ params: [
422
+ { name: "entityId", type: STRING, description: "Target entity id (defaults to @entity.id)", optional: true }
423
+ ],
424
+ example: '["despawn", "@entity.id"]',
425
+ effect: { kind: "despawn" }
426
+ },
427
+ "call-service": {
428
+ module: "core",
429
+ category: "effect",
430
+ minArity: 2,
431
+ maxArity: 3,
432
+ description: "Invoke an external service action",
433
+ hasSideEffects: true,
434
+ returnType: "void",
435
+ params: [
436
+ { name: "service", type: STRING, description: 'Service name (e.g. "llm", "stripe")' },
437
+ { name: "action", type: STRING, description: 'Service action (e.g. "generate", "charge")' },
438
+ {
439
+ name: "params",
440
+ type: { kind: "object", fields: {}, open: true },
441
+ description: "Service-specific params",
442
+ optional: true
443
+ }
444
+ ],
445
+ example: '["call-service", "llm", "generate", { "userPrompt": "@entity.inputText" }]',
446
+ effect: { kind: "call-service" }
447
+ },
448
+ "render-ui": {
449
+ module: "core",
450
+ category: "effect",
451
+ minArity: 2,
452
+ maxArity: 3,
453
+ description: "Render a pattern into a UI slot",
454
+ hasSideEffects: true,
455
+ returnType: "void",
456
+ params: [
457
+ { name: "slot", type: UI_SLOT, description: "Target UI slot (main, sidebar, modal, hud, ...)" },
458
+ {
459
+ name: "pattern",
460
+ type: {
461
+ kind: "union",
462
+ of: [
463
+ { kind: "object", fields: { patternType: PATTERN_TYPE }, open: true },
464
+ { kind: "literal", value: null }
465
+ ]
466
+ },
467
+ description: "Pattern config (or null to clear the slot)"
468
+ },
469
+ {
470
+ name: "props",
471
+ type: { kind: "object", fields: {}, open: true },
472
+ description: "Extra props forwarded to the pattern",
473
+ optional: true
474
+ }
475
+ ],
476
+ example: '["render-ui", "main", { "patternType": "entity-table", "columns": ["name"] }]',
477
+ effect: { kind: "render-ui" }
478
+ }
479
+ };
480
+ function getCoreOperators() {
481
+ return Object.keys(CORE_OPERATORS);
482
+ }
483
+
1
484
  // modules/math.ts
2
485
  var MATH_OPERATORS = {
3
486
  "math/abs": {
@@ -4324,6 +4807,6 @@ function getCompositionOperators() {
4324
4807
  return Object.keys(COMPOSITION_OPERATORS);
4325
4808
  }
4326
4809
 
4327
- export { AGENT_OPERATORS, ARRAY_OPERATORS, ASYNC_OPERATORS, COMPOSITION_OPERATORS, CONTRACT_OPERATORS, DATA_OPERATORS, FORMAT_OPERATORS, GRAPH_OPERATORS, MATH_OPERATORS, NN_OPERATORS, OBJECT_OPERATORS, OS_OPERATORS, PROB_OPERATORS, STR_OPERATORS, TENSOR_OPERATORS, TIME_OPERATORS, TRAIN_OPERATORS, VALIDATE_OPERATORS, getAgentOperators, getArrayOperators, getAsyncOperators, getCompositionOperators, getContractOperators, getDataOperators, getFormatOperators, getGraphOperators, getLambdaArrayOperators, getMathOperators, getNnOperators, getObjectOperators, getProbOperators, getStrOperators, getTensorOperators, getTimeOperators, getTrainOperators, getValidateOperators };
4810
+ export { AGENT_OPERATORS, ARRAY_OPERATORS, ASYNC_OPERATORS, COMPOSITION_OPERATORS, CONTRACT_OPERATORS, CORE_OPERATORS, DATA_OPERATORS, FORMAT_OPERATORS, GRAPH_OPERATORS, MATH_OPERATORS, NN_OPERATORS, OBJECT_OPERATORS, OS_OPERATORS, PROB_OPERATORS, STR_OPERATORS, TENSOR_OPERATORS, TIME_OPERATORS, TRAIN_OPERATORS, VALIDATE_OPERATORS, getAgentOperators, getArrayOperators, getAsyncOperators, getCompositionOperators, getContractOperators, getCoreOperators, getDataOperators, getFormatOperators, getGraphOperators, getLambdaArrayOperators, getMathOperators, getNnOperators, getObjectOperators, getProbOperators, getStrOperators, getTensorOperators, getTimeOperators, getTrainOperators, getValidateOperators };
4328
4811
  //# sourceMappingURL=index.js.map
4329
4812
  //# sourceMappingURL=index.js.map