@almadar/core 10.30.0 → 10.32.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.
@@ -1,1462 +1,11 @@
1
- import { A as AnyPatternConfig, b as EntityRow, c as EventId, T as TraitId, O as OrbitalId, d as EntityId, P as PageId, e as Entity, E as EntityField } from './pattern-types-CLcOXOmW.js';
2
- import { S as SExpr, E as EventPayload, a as Expression } from './expression-CB9R3KWk.js';
1
+ import { b as EventId, c as Effect, T as TraitId, O as OrbitalId, d as EntityId, P as PageId, A as AnyPatternConfig, e as Entity, E as EntityField } from './effect-8eas3tpU.js';
2
+ import { E as Expression, S as SExpr } from './expression-BlFrxmNB.js';
3
3
  import { z } from 'zod';
4
4
 
5
- /**
6
- * Service Types for Orbital Schema
7
- *
8
- * Defines external service integrations (REST APIs, WebSockets, MCP servers)
9
- * that can be used by orbital units via the `call_service` effect.
10
- *
11
- * @packageDocumentation
12
- */
13
-
14
- /**
15
- * Types of external services that can be integrated.
16
- */
17
- declare const SERVICE_TYPES: readonly ["rest", "socket", "mcp"];
18
- type ServiceType = (typeof SERVICE_TYPES)[number];
19
- declare const ServiceTypeSchema: z.ZodEnum<["rest", "socket", "mcp"]>;
20
- /**
21
- * Configuration for a REST API service.
22
- *
23
- * @example
24
- * ```typescript
25
- * const weatherService: RestServiceDef = {
26
- * name: 'WeatherAPI',
27
- * type: 'rest',
28
- * baseUrl: 'https://api.openweathermap.org/data/2.5',
29
- * headers: {
30
- * 'Content-Type': 'application/json',
31
- * },
32
- * auth: {
33
- * type: 'api-key',
34
- * keyName: 'appid',
35
- * location: 'query',
36
- * },
37
- * };
38
- * ```
39
- */
40
- interface RestServiceDef {
41
- /** Unique service name (used in call_service effect) */
42
- name: string;
43
- /** Service type */
44
- type: "rest";
45
- /** Optional description */
46
- description?: string;
47
- /** Base URL for the API */
48
- baseUrl: string;
49
- /** Default headers to include in all requests */
50
- headers?: Record<string, string>;
51
- /** Authentication configuration */
52
- auth?: RestAuthConfig;
53
- /** Timeout in milliseconds (default: 30000) */
54
- timeout?: number;
55
- }
56
- /**
57
- * Authentication configuration for REST services.
58
- */
59
- interface RestAuthConfig {
60
- /** Authentication type */
61
- type: "api-key" | "bearer" | "basic" | "oauth2";
62
- /** For api-key: the query parameter or header name */
63
- keyName?: string;
64
- /** For api-key: where to place the key */
65
- location?: "query" | "header";
66
- /** Environment variable name containing the secret (for secure storage) */
67
- secretEnv?: string;
68
- }
69
- declare const RestAuthConfigSchema: z.ZodObject<{
70
- type: z.ZodEnum<["api-key", "bearer", "basic", "oauth2"]>;
71
- keyName: z.ZodOptional<z.ZodString>;
72
- location: z.ZodOptional<z.ZodEnum<["query", "header"]>>;
73
- secretEnv: z.ZodOptional<z.ZodString>;
74
- }, "strip", z.ZodTypeAny, {
75
- type: "api-key" | "bearer" | "basic" | "oauth2";
76
- keyName?: string | undefined;
77
- location?: "query" | "header" | undefined;
78
- secretEnv?: string | undefined;
79
- }, {
80
- type: "api-key" | "bearer" | "basic" | "oauth2";
81
- keyName?: string | undefined;
82
- location?: "query" | "header" | undefined;
83
- secretEnv?: string | undefined;
84
- }>;
85
- declare const RestServiceDefSchema: z.ZodObject<{
86
- name: z.ZodString;
87
- type: z.ZodLiteral<"rest">;
88
- description: z.ZodOptional<z.ZodString>;
89
- baseUrl: z.ZodString;
90
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
91
- auth: z.ZodOptional<z.ZodObject<{
92
- type: z.ZodEnum<["api-key", "bearer", "basic", "oauth2"]>;
93
- keyName: z.ZodOptional<z.ZodString>;
94
- location: z.ZodOptional<z.ZodEnum<["query", "header"]>>;
95
- secretEnv: z.ZodOptional<z.ZodString>;
96
- }, "strip", z.ZodTypeAny, {
97
- type: "api-key" | "bearer" | "basic" | "oauth2";
98
- keyName?: string | undefined;
99
- location?: "query" | "header" | undefined;
100
- secretEnv?: string | undefined;
101
- }, {
102
- type: "api-key" | "bearer" | "basic" | "oauth2";
103
- keyName?: string | undefined;
104
- location?: "query" | "header" | undefined;
105
- secretEnv?: string | undefined;
106
- }>>;
107
- timeout: z.ZodOptional<z.ZodNumber>;
108
- }, "strip", z.ZodTypeAny, {
109
- type: "rest";
110
- name: string;
111
- baseUrl: string;
112
- description?: string | undefined;
113
- headers?: Record<string, string> | undefined;
114
- auth?: {
115
- type: "api-key" | "bearer" | "basic" | "oauth2";
116
- keyName?: string | undefined;
117
- location?: "query" | "header" | undefined;
118
- secretEnv?: string | undefined;
119
- } | undefined;
120
- timeout?: number | undefined;
121
- }, {
122
- type: "rest";
123
- name: string;
124
- baseUrl: string;
125
- description?: string | undefined;
126
- headers?: Record<string, string> | undefined;
127
- auth?: {
128
- type: "api-key" | "bearer" | "basic" | "oauth2";
129
- keyName?: string | undefined;
130
- location?: "query" | "header" | undefined;
131
- secretEnv?: string | undefined;
132
- } | undefined;
133
- timeout?: number | undefined;
134
- }>;
135
- /**
136
- * Configuration for a WebSocket service.
137
- *
138
- * @example
139
- * ```typescript
140
- * const chatService: SocketServiceDef = {
141
- * name: 'ChatSocket',
142
- * type: 'socket',
143
- * url: 'wss://chat.example.com',
144
- * events: {
145
- * inbound: ['message_received', 'user_joined', 'user_left'],
146
- * outbound: ['send_message', 'join_room', 'leave_room'],
147
- * },
148
- * };
149
- * ```
150
- */
151
- interface SocketServiceDef {
152
- /** Unique service name */
153
- name: string;
154
- /** Service type */
155
- type: "socket";
156
- /** Optional description */
157
- description?: string;
158
- /** WebSocket URL */
159
- url: string;
160
- /** Event definitions */
161
- events: SocketEvents;
162
- /** Reconnection configuration */
163
- reconnect?: {
164
- /** Enable automatic reconnection */
165
- enabled: boolean;
166
- /** Maximum reconnection attempts */
167
- maxAttempts?: number;
168
- /** Delay between attempts in ms */
169
- delayMs?: number;
170
- };
171
- }
172
- /**
173
- * Socket event definitions.
174
- */
175
- interface SocketEvents {
176
- /** Events received from server (maps to orbital events) */
177
- inbound: string[];
178
- /** Events sent to server (triggered by effects) */
179
- outbound: string[];
180
- }
181
- declare const SocketEventsSchema: z.ZodObject<{
182
- inbound: z.ZodArray<z.ZodString, "many">;
183
- outbound: z.ZodArray<z.ZodString, "many">;
184
- }, "strip", z.ZodTypeAny, {
185
- inbound: string[];
186
- outbound: string[];
187
- }, {
188
- inbound: string[];
189
- outbound: string[];
190
- }>;
191
- declare const SocketServiceDefSchema: z.ZodObject<{
192
- name: z.ZodString;
193
- type: z.ZodLiteral<"socket">;
194
- description: z.ZodOptional<z.ZodString>;
195
- url: z.ZodString;
196
- events: z.ZodObject<{
197
- inbound: z.ZodArray<z.ZodString, "many">;
198
- outbound: z.ZodArray<z.ZodString, "many">;
199
- }, "strip", z.ZodTypeAny, {
200
- inbound: string[];
201
- outbound: string[];
202
- }, {
203
- inbound: string[];
204
- outbound: string[];
205
- }>;
206
- reconnect: z.ZodOptional<z.ZodObject<{
207
- enabled: z.ZodBoolean;
208
- maxAttempts: z.ZodOptional<z.ZodNumber>;
209
- delayMs: z.ZodOptional<z.ZodNumber>;
210
- }, "strip", z.ZodTypeAny, {
211
- enabled: boolean;
212
- maxAttempts?: number | undefined;
213
- delayMs?: number | undefined;
214
- }, {
215
- enabled: boolean;
216
- maxAttempts?: number | undefined;
217
- delayMs?: number | undefined;
218
- }>>;
219
- }, "strip", z.ZodTypeAny, {
220
- type: "socket";
221
- url: string;
222
- name: string;
223
- events: {
224
- inbound: string[];
225
- outbound: string[];
226
- };
227
- description?: string | undefined;
228
- reconnect?: {
229
- enabled: boolean;
230
- maxAttempts?: number | undefined;
231
- delayMs?: number | undefined;
232
- } | undefined;
233
- }, {
234
- type: "socket";
235
- url: string;
236
- name: string;
237
- events: {
238
- inbound: string[];
239
- outbound: string[];
240
- };
241
- description?: string | undefined;
242
- reconnect?: {
243
- enabled: boolean;
244
- maxAttempts?: number | undefined;
245
- delayMs?: number | undefined;
246
- } | undefined;
247
- }>;
248
- /**
249
- * Configuration for an MCP (Model Context Protocol) server.
250
- *
251
- * @example
252
- * ```typescript
253
- * const mcpService: McpServiceDef = {
254
- * name: 'DatabaseMCP',
255
- * type: 'mcp',
256
- * serverPath: './mcp-servers/database',
257
- * capabilities: ['query', 'insert', 'update'],
258
- * };
259
- * ```
260
- */
261
- interface McpServiceDef {
262
- /** Unique service name */
263
- name: string;
264
- /** Service type */
265
- type: "mcp";
266
- /** Optional description */
267
- description?: string;
268
- /** Path to MCP server executable or module */
269
- serverPath: string;
270
- /** List of capabilities/tools exposed by the MCP server */
271
- capabilities: string[];
272
- /** Environment variables to pass to the MCP server */
273
- env?: Record<string, string>;
274
- }
275
- declare const McpServiceDefSchema: z.ZodObject<{
276
- name: z.ZodString;
277
- type: z.ZodLiteral<"mcp">;
278
- description: z.ZodOptional<z.ZodString>;
279
- serverPath: z.ZodString;
280
- capabilities: z.ZodArray<z.ZodString, "many">;
281
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
282
- }, "strip", z.ZodTypeAny, {
283
- type: "mcp";
284
- name: string;
285
- serverPath: string;
286
- capabilities: string[];
287
- description?: string | undefined;
288
- env?: Record<string, string> | undefined;
289
- }, {
290
- type: "mcp";
291
- name: string;
292
- serverPath: string;
293
- capabilities: string[];
294
- description?: string | undefined;
295
- env?: Record<string, string> | undefined;
296
- }>;
297
- /**
298
- * Union type for all service definitions.
299
- */
300
- type ServiceDefinition = RestServiceDef | SocketServiceDef | McpServiceDef;
301
- declare const ServiceDefinitionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
302
- name: z.ZodString;
303
- type: z.ZodLiteral<"rest">;
304
- description: z.ZodOptional<z.ZodString>;
305
- baseUrl: z.ZodString;
306
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
307
- auth: z.ZodOptional<z.ZodObject<{
308
- type: z.ZodEnum<["api-key", "bearer", "basic", "oauth2"]>;
309
- keyName: z.ZodOptional<z.ZodString>;
310
- location: z.ZodOptional<z.ZodEnum<["query", "header"]>>;
311
- secretEnv: z.ZodOptional<z.ZodString>;
312
- }, "strip", z.ZodTypeAny, {
313
- type: "api-key" | "bearer" | "basic" | "oauth2";
314
- keyName?: string | undefined;
315
- location?: "query" | "header" | undefined;
316
- secretEnv?: string | undefined;
317
- }, {
318
- type: "api-key" | "bearer" | "basic" | "oauth2";
319
- keyName?: string | undefined;
320
- location?: "query" | "header" | undefined;
321
- secretEnv?: string | undefined;
322
- }>>;
323
- timeout: z.ZodOptional<z.ZodNumber>;
324
- }, "strip", z.ZodTypeAny, {
325
- type: "rest";
326
- name: string;
327
- baseUrl: string;
328
- description?: string | undefined;
329
- headers?: Record<string, string> | undefined;
330
- auth?: {
331
- type: "api-key" | "bearer" | "basic" | "oauth2";
332
- keyName?: string | undefined;
333
- location?: "query" | "header" | undefined;
334
- secretEnv?: string | undefined;
335
- } | undefined;
336
- timeout?: number | undefined;
337
- }, {
338
- type: "rest";
339
- name: string;
340
- baseUrl: string;
341
- description?: string | undefined;
342
- headers?: Record<string, string> | undefined;
343
- auth?: {
344
- type: "api-key" | "bearer" | "basic" | "oauth2";
345
- keyName?: string | undefined;
346
- location?: "query" | "header" | undefined;
347
- secretEnv?: string | undefined;
348
- } | undefined;
349
- timeout?: number | undefined;
350
- }>, z.ZodObject<{
351
- name: z.ZodString;
352
- type: z.ZodLiteral<"socket">;
353
- description: z.ZodOptional<z.ZodString>;
354
- url: z.ZodString;
355
- events: z.ZodObject<{
356
- inbound: z.ZodArray<z.ZodString, "many">;
357
- outbound: z.ZodArray<z.ZodString, "many">;
358
- }, "strip", z.ZodTypeAny, {
359
- inbound: string[];
360
- outbound: string[];
361
- }, {
362
- inbound: string[];
363
- outbound: string[];
364
- }>;
365
- reconnect: z.ZodOptional<z.ZodObject<{
366
- enabled: z.ZodBoolean;
367
- maxAttempts: z.ZodOptional<z.ZodNumber>;
368
- delayMs: z.ZodOptional<z.ZodNumber>;
369
- }, "strip", z.ZodTypeAny, {
370
- enabled: boolean;
371
- maxAttempts?: number | undefined;
372
- delayMs?: number | undefined;
373
- }, {
374
- enabled: boolean;
375
- maxAttempts?: number | undefined;
376
- delayMs?: number | undefined;
377
- }>>;
378
- }, "strip", z.ZodTypeAny, {
379
- type: "socket";
380
- url: string;
381
- name: string;
382
- events: {
383
- inbound: string[];
384
- outbound: string[];
385
- };
386
- description?: string | undefined;
387
- reconnect?: {
388
- enabled: boolean;
389
- maxAttempts?: number | undefined;
390
- delayMs?: number | undefined;
391
- } | undefined;
392
- }, {
393
- type: "socket";
394
- url: string;
395
- name: string;
396
- events: {
397
- inbound: string[];
398
- outbound: string[];
399
- };
400
- description?: string | undefined;
401
- reconnect?: {
402
- enabled: boolean;
403
- maxAttempts?: number | undefined;
404
- delayMs?: number | undefined;
405
- } | undefined;
406
- }>, z.ZodObject<{
407
- name: z.ZodString;
408
- type: z.ZodLiteral<"mcp">;
409
- description: z.ZodOptional<z.ZodString>;
410
- serverPath: z.ZodString;
411
- capabilities: z.ZodArray<z.ZodString, "many">;
412
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
413
- }, "strip", z.ZodTypeAny, {
414
- type: "mcp";
415
- name: string;
416
- serverPath: string;
417
- capabilities: string[];
418
- description?: string | undefined;
419
- env?: Record<string, string> | undefined;
420
- }, {
421
- type: "mcp";
422
- name: string;
423
- serverPath: string;
424
- capabilities: string[];
425
- description?: string | undefined;
426
- env?: Record<string, string> | undefined;
427
- }>]>;
428
- /**
429
- * ServiceRef - Service can be inline definition, reference object with overrides,
430
- * or bare string reference to an imported service.
431
- *
432
- * Reference format: "Alias.services.ServiceName"
433
- */
434
- type ServiceRef = ServiceDefinition | ServiceRefObject | string;
435
- /**
436
- * Phase F: Service reference object with override fields.
437
- *
438
- * Mirrors the Rust `ServiceRefObject` at
439
- * `orbital-rust/crates/orbital-core/src/schema/types.rs:353-375`. A caller
440
- * imports a service via `uses[]`, references it by `ref`, and supplies
441
- * any subset of these fields to override the imported service's defaults
442
- * during inlining.
443
- *
444
- * @example
445
- * ```typescript
446
- * const ref: ServiceRefObject = {
447
- * ref: "Weather.services.openweather",
448
- * baseUrl: "https://staging.weather.example.com",
449
- * headers: { "X-Tenant": "acme" },
450
- * };
451
- * ```
452
- */
453
- interface ServiceRefObject {
454
- /** Reference to imported service: "Alias.services.ServiceName" */
455
- ref: string;
456
- /** Override the service description */
457
- description?: string;
458
- /** Override the REST baseUrl */
459
- baseUrl?: string;
460
- /** Override or merge default headers (caller wins on key collision) */
461
- headers?: Record<string, string>;
462
- /** Override the WebSocket url */
463
- url?: string;
464
- /** Override the MCP server path */
465
- serverPath?: string;
466
- }
467
- /**
468
- * Checks if a service reference is a bare string reference.
469
- *
470
- * Type guard to determine if a service reference is a string reference
471
- * (format: "Alias.services.ServiceName") rather than an inline service
472
- * definition or a reference object.
473
- *
474
- * @param {ServiceRef} service - Service reference to check
475
- * @returns {boolean} True if service is a string reference, false otherwise
476
- *
477
- * @example
478
- * isServiceReference("Weather.services.openweather"); // returns true
479
- * isServiceReference({ name: "weather", type: "rest" }); // returns false
480
- * isServiceReference({ ref: "Weather.services.openweather" }); // returns false
481
- */
482
- declare function isServiceReference(service: ServiceRef): service is string;
483
- /**
484
- * Phase F: Type guard for `ServiceRefObject` (the override-carrying form).
485
- *
486
- * @param {ServiceRef} service - Service reference to check
487
- * @returns {boolean} True if service is a ServiceRefObject
488
- */
489
- declare function isServiceReferenceObject(service: ServiceRef): service is ServiceRefObject;
490
- /**
491
- * Validate service reference format: "Alias.services.ServiceName"
492
- */
493
- declare const ServiceRefStringSchema: z.ZodString;
494
- declare const ServiceRefObjectSchema: z.ZodObject<{
495
- ref: z.ZodString;
496
- description: z.ZodOptional<z.ZodString>;
497
- baseUrl: z.ZodOptional<z.ZodString>;
498
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
499
- url: z.ZodOptional<z.ZodString>;
500
- serverPath: z.ZodOptional<z.ZodString>;
501
- }, "strip", z.ZodTypeAny, {
502
- ref: string;
503
- url?: string | undefined;
504
- description?: string | undefined;
505
- baseUrl?: string | undefined;
506
- headers?: Record<string, string> | undefined;
507
- serverPath?: string | undefined;
508
- }, {
509
- ref: string;
510
- url?: string | undefined;
511
- description?: string | undefined;
512
- baseUrl?: string | undefined;
513
- headers?: Record<string, string> | undefined;
514
- serverPath?: string | undefined;
515
- }>;
516
- declare const ServiceRefSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
517
- name: z.ZodString;
518
- type: z.ZodLiteral<"rest">;
519
- description: z.ZodOptional<z.ZodString>;
520
- baseUrl: z.ZodString;
521
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
522
- auth: z.ZodOptional<z.ZodObject<{
523
- type: z.ZodEnum<["api-key", "bearer", "basic", "oauth2"]>;
524
- keyName: z.ZodOptional<z.ZodString>;
525
- location: z.ZodOptional<z.ZodEnum<["query", "header"]>>;
526
- secretEnv: z.ZodOptional<z.ZodString>;
527
- }, "strip", z.ZodTypeAny, {
528
- type: "api-key" | "bearer" | "basic" | "oauth2";
529
- keyName?: string | undefined;
530
- location?: "query" | "header" | undefined;
531
- secretEnv?: string | undefined;
532
- }, {
533
- type: "api-key" | "bearer" | "basic" | "oauth2";
534
- keyName?: string | undefined;
535
- location?: "query" | "header" | undefined;
536
- secretEnv?: string | undefined;
537
- }>>;
538
- timeout: z.ZodOptional<z.ZodNumber>;
539
- }, "strip", z.ZodTypeAny, {
540
- type: "rest";
541
- name: string;
542
- baseUrl: string;
543
- description?: string | undefined;
544
- headers?: Record<string, string> | undefined;
545
- auth?: {
546
- type: "api-key" | "bearer" | "basic" | "oauth2";
547
- keyName?: string | undefined;
548
- location?: "query" | "header" | undefined;
549
- secretEnv?: string | undefined;
550
- } | undefined;
551
- timeout?: number | undefined;
552
- }, {
553
- type: "rest";
554
- name: string;
555
- baseUrl: string;
556
- description?: string | undefined;
557
- headers?: Record<string, string> | undefined;
558
- auth?: {
559
- type: "api-key" | "bearer" | "basic" | "oauth2";
560
- keyName?: string | undefined;
561
- location?: "query" | "header" | undefined;
562
- secretEnv?: string | undefined;
563
- } | undefined;
564
- timeout?: number | undefined;
565
- }>, z.ZodObject<{
566
- name: z.ZodString;
567
- type: z.ZodLiteral<"socket">;
568
- description: z.ZodOptional<z.ZodString>;
569
- url: z.ZodString;
570
- events: z.ZodObject<{
571
- inbound: z.ZodArray<z.ZodString, "many">;
572
- outbound: z.ZodArray<z.ZodString, "many">;
573
- }, "strip", z.ZodTypeAny, {
574
- inbound: string[];
575
- outbound: string[];
576
- }, {
577
- inbound: string[];
578
- outbound: string[];
579
- }>;
580
- reconnect: z.ZodOptional<z.ZodObject<{
581
- enabled: z.ZodBoolean;
582
- maxAttempts: z.ZodOptional<z.ZodNumber>;
583
- delayMs: z.ZodOptional<z.ZodNumber>;
584
- }, "strip", z.ZodTypeAny, {
585
- enabled: boolean;
586
- maxAttempts?: number | undefined;
587
- delayMs?: number | undefined;
588
- }, {
589
- enabled: boolean;
590
- maxAttempts?: number | undefined;
591
- delayMs?: number | undefined;
592
- }>>;
593
- }, "strip", z.ZodTypeAny, {
594
- type: "socket";
595
- url: string;
596
- name: string;
597
- events: {
598
- inbound: string[];
599
- outbound: string[];
600
- };
601
- description?: string | undefined;
602
- reconnect?: {
603
- enabled: boolean;
604
- maxAttempts?: number | undefined;
605
- delayMs?: number | undefined;
606
- } | undefined;
607
- }, {
608
- type: "socket";
609
- url: string;
610
- name: string;
611
- events: {
612
- inbound: string[];
613
- outbound: string[];
614
- };
615
- description?: string | undefined;
616
- reconnect?: {
617
- enabled: boolean;
618
- maxAttempts?: number | undefined;
619
- delayMs?: number | undefined;
620
- } | undefined;
621
- }>, z.ZodObject<{
622
- name: z.ZodString;
623
- type: z.ZodLiteral<"mcp">;
624
- description: z.ZodOptional<z.ZodString>;
625
- serverPath: z.ZodString;
626
- capabilities: z.ZodArray<z.ZodString, "many">;
627
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
628
- }, "strip", z.ZodTypeAny, {
629
- type: "mcp";
630
- name: string;
631
- serverPath: string;
632
- capabilities: string[];
633
- description?: string | undefined;
634
- env?: Record<string, string> | undefined;
635
- }, {
636
- type: "mcp";
637
- name: string;
638
- serverPath: string;
639
- capabilities: string[];
640
- description?: string | undefined;
641
- env?: Record<string, string> | undefined;
642
- }>]>, z.ZodObject<{
643
- ref: z.ZodString;
644
- description: z.ZodOptional<z.ZodString>;
645
- baseUrl: z.ZodOptional<z.ZodString>;
646
- headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
647
- url: z.ZodOptional<z.ZodString>;
648
- serverPath: z.ZodOptional<z.ZodString>;
649
- }, "strip", z.ZodTypeAny, {
650
- ref: string;
651
- url?: string | undefined;
652
- description?: string | undefined;
653
- baseUrl?: string | undefined;
654
- headers?: Record<string, string> | undefined;
655
- serverPath?: string | undefined;
656
- }, {
657
- ref: string;
658
- url?: string | undefined;
659
- description?: string | undefined;
660
- baseUrl?: string | undefined;
661
- headers?: Record<string, string> | undefined;
662
- serverPath?: string | undefined;
663
- }>, z.ZodString]>;
664
- /**
665
- * Parses a service reference into its components.
666
- *
667
- * Extracts the alias and service name from a service reference string
668
- * in format "Alias.services.ServiceName". Returns null if not a valid reference.
669
- *
670
- * @param {string} ref - Service reference string
671
- * @returns {{ alias: string; serviceName: string } | null} Parsed components or null
672
- *
673
- * @example
674
- * parseServiceRef("Weather.services.openweather"); // returns { alias: "Weather", serviceName: "openweather" }
675
- * parseServiceRef("invalid"); // returns null
676
- */
677
- declare function parseServiceRef(ref: string): {
678
- alias: string;
679
- serviceName: string;
680
- } | null;
681
- /**
682
- * Checks if a service definition is a REST service.
683
- *
684
- * Type guard to determine if a service definition represents a REST API service.
685
- * Used for service type discrimination and validation.
686
- *
687
- * @param {ServiceDefinition} service - Service definition to check
688
- * @returns {boolean} True if service is a REST service, false otherwise
689
- *
690
- * @example
691
- * isRestService({ name: "weather", type: "rest", baseUrl: "..." }); // returns true
692
- * isRestService({ name: "chat", type: "socket" }); // returns false
693
- */
694
- declare function isRestService(service: ServiceDefinition): service is RestServiceDef;
695
- /**
696
- * Checks if a service definition is a Socket service.
697
- *
698
- * Type guard to determine if a service definition represents a WebSocket service.
699
- * Used for service type discrimination and validation.
700
- *
701
- * @param {ServiceDefinition} service - Service definition to check
702
- * @returns {boolean} True if service is a Socket service, false otherwise
703
- *
704
- * @example
705
- * isSocketService({ name: "chat", type: "socket", url: "wss://..." }); // returns true
706
- * isSocketService({ name: "weather", type: "rest" }); // returns false
707
- */
708
- declare function isSocketService(service: ServiceDefinition): service is SocketServiceDef;
709
- /**
710
- * Checks if a service definition is an MCP service.
711
- *
712
- * Type guard to determine if a service definition represents an MCP
713
- * (Multiplayer Control Protocol) service. Used for service type discrimination.
714
- *
715
- * @param {ServiceDefinition} service - Service definition to check
716
- * @returns {boolean} True if service is an MCP service, false otherwise
717
- *
718
- * @example
719
- * isMcpService({ name: "game", type: "mcp", serverUrl: "..." }); // returns true
720
- * isMcpService({ name: "chat", type: "socket" }); // returns false
721
- */
722
- declare function isMcpService(service: ServiceDefinition): service is McpServiceDef;
723
- /**
724
- * Get all service names from a list of services.
725
- */
726
- declare function getServiceNames(services: ServiceDefinition[]): string[];
727
- /**
728
- * Find a service by name.
729
- */
730
- declare function findService(services: ServiceDefinition[], name: string): ServiceDefinition | undefined;
731
- /**
732
- * Check if a service name exists (case-insensitive).
733
- */
734
- declare function hasService(services: ServiceDefinition[], name: string): boolean;
735
- /**
736
- * Allowed leaf value for `ServiceParams`. Mirrors `EventPayloadValue`'s
737
- * recursive-array shape so integration call signatures can express the
738
- * nested structures real services need (port mappings, volume mounts,
739
- * pagination cursors), and so a value satisfying `EventPayloadValue`
740
- * also satisfies `ServiceParamsValue` without a cast — the same data
741
- * flows through `call-service` and `emit` without boundary widening.
742
- */
743
- type ServiceParamsValue = string | number | boolean | Date | null | undefined | ServiceParams | readonly ServiceParamsValue[];
744
- /** Parameters passed to call-service effects. Recursive for nested request shapes. */
745
- interface ServiceParams {
746
- [key: string]: ServiceParamsValue;
747
- }
748
-
749
- /**
750
- * Effect Types (Self-Contained)
751
- *
752
- * Defines effect types for trait transitions and ticks.
753
- * Effects are S-expressions (arrays) that describe actions to perform.
754
- *
755
- * @packageDocumentation
756
- */
757
-
758
- /**
759
- * Known UI slots where content can be rendered
760
- */
761
- declare const UI_SLOTS: readonly ["main", "sidebar", "modal", "drawer", "overlay", "center", "toast", "floating", "system", "content", "screen", "hud", "hud-top", "hud-bottom", "hud.health", "hud.score", "hud.inventory", "hud.stamina", "overlay.inventory", "overlay.dialogue", "overlay.menu", "overlay.pause"];
762
- type UISlot = (typeof UI_SLOTS)[number];
763
- declare const UISlotSchema: z.ZodEnum<["main", "sidebar", "modal", "drawer", "overlay", "center", "toast", "floating", "system", "content", "screen", "hud", "hud-top", "hud-bottom", "hud.health", "hud.score", "hud.inventory", "hud.stamina", "overlay.inventory", "overlay.dialogue", "overlay.menu", "overlay.pause"]>;
764
-
765
- /**
766
- * Configuration extracted from call-service effects
767
- */
768
- interface CallServiceConfig {
769
- service: string;
770
- action: string;
771
- endpoint?: string;
772
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
773
- params?: ServiceParams;
774
- onSuccess?: string;
775
- onError?: string;
776
- }
777
- /**
778
- * A binding reference to a render tree stored elsewhere — a trait `config`
779
- * knob or a payload field — e.g. `"@config.bodyContent"`. Resolved to a pattern
780
- * node at render time. This is how an atom renders a tree that contains data
781
- * bindings (`entity: "@payload.data"`, `fields: "@config.fields"`): the tree is
782
- * a permissive `TraitConfigValue` stored in `config` (a binding string is not a
783
- * valid `AnyPatternConfig` prop value), and the render-ui effect points at it.
784
- * Worked example: `std-browse`'s loaded transition is `['render-ui', 'main',
785
- * '@config.bodyContent']`. The Rust validator accepts this form; this variant
786
- * lets the TS effect type express it.
787
- */
788
- type RenderBinding = `@${string}`;
789
- /**
790
- * Render UI effect - displays a pattern in a UI slot.
791
- * @example ['render-ui', 'main', { patternType: 'entity-table', columns: ['name'] }]
792
- * @example ['render-ui', 'main', '@config.bodyContent'] // a {@link RenderBinding} target
793
- */
794
- type RenderUIEffect = ['render-ui', UISlot, AnyPatternConfig] | ['render-ui', UISlot, AnyPatternConfig, ResolvedPatternProps] | ['render-ui', UISlot, RenderBinding] | ['render-ui', UISlot, null];
795
- /**
796
- * Lambda expression for per-item rendering in data-grid/data-list.
797
- * The compiler generates: {(paramName: Record<string, unknown>) => (<>JSX</>)}
798
- * where @{paramName}.field bindings reference the current iteration item.
799
- *
800
- * @example ["fn", "item", { "type": "stack", "children": [{ "type": "typography", "content": "@item.title" }] }]
801
- */
802
- type RenderItemLambda = ['fn', string, AnyPatternConfig];
803
- /**
804
- * Dynamic-collection children entry: renders one child per item of a collection
805
- * expression, authored inline in a `children:` position and kept verbatim as IR
806
- * (no new node kind). The collection expression is an {@link SExpr} evaluated at
807
- * render time; the {@link RenderItemLambda} body is instantiated per item with
808
- * the lambda param bound as an `@item`-scope binding. Both execution paths lower
809
- * onto the one lambda + `@item` + splice machinery.
810
- *
811
- * @example ["array/map", "@entity.tasks", ["fn", "item", { "type": "typography", "content": "@item.title" }]]
812
- */
813
- type RenderChildrenMap = ['array/map', SExpr, RenderItemLambda];
814
- /**
815
- * Navigate effect - navigates to an internal page path or an external URL.
816
- * @example ['navigate', '/tasks'] or ['navigate', '/tasks/:id', { id: '123' }]
817
- * @example ['navigate', 'https://example.com']
818
- */
819
- type NavigateEffect = ['navigate', string | SExpr] | ['navigate', string | SExpr, Record<string, string>];
820
- /**
821
- * Emit effect - emits an event, optionally with payload.
822
- * @example ['emit', 'SAVE'] or ['emit', 'PLAYER_DIED', { playerId: '@entity.id' }]
823
- * @example ['emit', 'FILTER_CHANGED', '@entity.filters']
824
- */
825
- type EmitEffect = ['emit', string] | ['emit', string, EventPayload | string];
826
- /**
827
- * `emit:` config block attached to async / reactive data operators.
828
- *
829
- * Each key names an event the runtime should fire on the bus when the
830
- * effect reaches the corresponding lifecycle point. The set of keys an
831
- * operator actually supports is enforced by the compiler validator:
832
- *
833
- * | Operator | Supported keys |
834
- * |------------------|---------------------------|
835
- * | `fetch` | `success`, `failure` |
836
- * | `persist` | `success`, `failure` |
837
- * | `call-service` | `success`, `failure` |
838
- * | `set` | `success` |
839
- * | `ref` | `on_change`, `failure` |
840
- * | `os/watch-*` | `on_message`, `failure` |
841
- *
842
- * Payload convention:
843
- * - `success` / `on_change` → the effect's result (fetched entity, new value)
844
- * - `failure` → `{ error: string, code?: string }`
845
- * - `on_message` → the incoming message (os/watch-* streams)
846
- *
847
- * See `docs/Almadar_Std_Gaps.md` §3.1 for the close-the-circuit design.
848
- */
849
- interface EmitConfig {
850
- /** Fires after a one-shot async effect resolves successfully. */
851
- success?: string;
852
- /** Fires when the effect throws; payload is `{ error: string }`. */
853
- failure?: string;
854
- /** Reactive-subscription event (per update for `ref`). */
855
- on_change?: string;
856
- /** Per-event fire for `os/watch-*` streams. */
857
- on_message?: string;
858
- }
859
- /**
860
- * Set effect - sets a binding to a value.
861
- *
862
- * Two forms are supported to match the runtime's `set` handler signature
863
- * `(targetId, field, value)`:
864
- *
865
- * - 3-element binding form (legacy / std behaviors): ['set', '@entity.field', value]
866
- * - 4-element target form (canonical runtime): ['set', entityId, fieldName, value]
867
- *
868
- * The 4-element form is what `OrbitalServerRuntime`'s set handler
869
- * dispatches directly (`update(entityType, targetId, { field: value })`).
870
- * Prefer the 4-element form when authoring schemas in TypeScript that
871
- * load directly into the runtime.
872
- *
873
- * @example ['set', '@entity.health', 100] // 3-element
874
- * @example ['set', '@entity.id', 'health', 100] // 4-element
875
- * @example ['set', '@entity.id', 'count', ['+', '@entity.count', 1]]
876
- */
877
- type SetEffect = ['set', string, unknown] | ['set', string, string, unknown];
878
- /**
879
- * Trailing config object on persist effects. When present, it carries the
880
- * `emit` map specifying which events to fire on persist success/failure.
881
- * Mirrors what the runtime's `EffectExecutor` reads at the 5th tuple
882
- * position. See `(persist create Entity @payload.data { emit: { success:
883
- * "Saved", failure: "SaveFailed" } })` in `.lolo` source.
884
- */
885
- interface PersistEmitConfig {
886
- emit?: {
887
- success?: string;
888
- failure?: string;
889
- };
890
- }
891
- /**
892
- * Persist effect data argument: either an entity row literal (field map)
893
- * or a binding string referencing a row in scope (e.g. `@payload.data`,
894
- * `@entity`). At runtime, binding strings resolve to `EntityRow` values
895
- * before the persist op runs.
896
- */
897
- type PersistData = EntityRow | string;
898
- /**
899
- * Persist effect - creates, updates, deletes, or clears entities.
900
- *
901
- * Each operation accepts an optional trailing `PersistEmitConfig` so the
902
- * runtime can fire success / failure events when the operation completes.
903
- *
904
- * @example ['persist', 'create', 'Task', { title: '@payload.title' }]
905
- * @example ['persist', 'update', '@entity.entityType', '@payload.data']
906
- * @example ['persist', 'create', 'Task', '@payload.data', { emit: { success: 'TaskCreated' } }]
907
- */
908
- type PersistEffect = ['persist', 'create', string, PersistData] | ['persist', 'create', string, PersistData, PersistEmitConfig] | ['persist', 'update', string, PersistData] | ['persist', 'update', string, PersistData, PersistEmitConfig] | ['persist', 'delete', string] | ['persist', 'delete', string, PersistData] | ['persist', 'delete', string, PersistData, PersistEmitConfig] | ['persist', 'clear', string] | ['persist', 'clear', string, PersistData] | ['persist', 'clear', string, PersistData, PersistEmitConfig];
909
- /**
910
- * Call service effect - invokes an external service.
911
- *
912
- * Two shapes are accepted:
913
- *
914
- * 1. Flat form (what the runtime reads and every .orb file uses):
915
- * `['call-service', serviceName, action, params?]` — args[0]=service,
916
- * args[1]=action, args[2]=params. This is the canonical form; the
917
- * runtime's EffectExecutor decodes exactly these positions.
918
- *
919
- * 2. Legacy config-object form (kept for the `callService()` helper):
920
- * `['call-service', serviceName, CallServiceConfig]` — retained so
921
- * older call sites using the builder helper continue to typecheck.
922
- *
923
- * @example ['call-service', 'llm', 'generate', { userPrompt: '@entity.inputText' }]
924
- * @example ['call-service', 'llm', 'generate', { userPrompt: '...' }, { emit: { success: 'OK', failure: 'ERR' } }]
925
- * @example ['call-service', 'WeatherAPI', { service: 'weather', action: 'get', onSuccess: 'OK' }]
926
- */
927
- type CallServiceEffect = ['call-service', string, string] | ['call-service', string, string, ServiceParams] | ['call-service', string, string, ServiceParams, PersistEmitConfig] | ['call-service', string, CallServiceConfig];
928
- /**
929
- * Spawn effect - creates a new entity instance (games).
930
- * @example ['spawn', 'Bullet', { x: '@entity.x', y: '@entity.y' }]
931
- */
932
- type SpawnEffect = ['spawn', string] | ['spawn', string, EntityRow];
933
- /**
934
- * Despawn effect - removes an entity instance (games).
935
- * @example ['despawn', '@entity.id']
936
- */
937
- type DespawnEffect = ['despawn', string];
938
- /**
939
- * Do effect - executes multiple effects in sequence.
940
- * Uses SExpr to allow deeply nested conditionals.
941
- * @example ['do', ['set', '@entity.x', 0], ['set', '@entity.y', 0]]
942
- */
943
- type DoEffect = ['do', ...SExpr[]];
944
- /**
945
- * Notify effect - sends a notification.
946
- * @example ['notify', 'in_app', 'Task created successfully']
947
- * @example ['notify', 'in_app', ['str/concat', 'Item: ', '@entity.name']]
948
- */
949
- type NotifyEffect = ['notify', string, string | SExpr] | ['notify', string, string | SExpr, string];
950
- /**
951
- * Options accepted by `fetch` / `ref` / `deref` effects. Mirrors what
952
- * `OrbitalServerRuntime`'s fetch handler reads at runtime: `id`, `filter`,
953
- * `limit`, `offset`, `include`, plus the trailing `emit:` map for
954
- * success/failure event names.
955
- */
956
- interface FetchOptions {
957
- /** Fetch a single entity by ID */
958
- id?: string;
959
- /** Filter expression (S-expression) */
960
- filter?: SExpr;
961
- /** Maximum number of entities to return */
962
- limit?: number;
963
- /** Number of entities to skip */
964
- offset?: number;
965
- /** Relations to populate (entity field names) */
966
- include?: string[];
967
- /** Lifecycle events to emit on resolve / reject */
968
- emit?: {
969
- success?: string;
970
- failure?: string;
971
- };
972
- }
973
- /**
974
- * Fetch effect - retrieves entity data (server-side).
975
- * @example ['fetch', 'User'] or ['fetch', 'User', { id: '@payload.userId' }]
976
- */
977
- type FetchEffect = ['fetch', string] | ['fetch', string, FetchOptions];
978
- /**
979
- * Result returned by a fetch / ref / deref handler.
980
- *
981
- * `rows` carries the entity (or entities) that survived `filter` AND
982
- * pagination (`offset`/`limit`). `total` is the count of rows that
983
- * matched the filter BEFORE pagination, so paginating consumers can
984
- * compute `totalPages = ceil(total / pageSize)` without a second
985
- * round-trip. Single-entity fetches by id return `total: 1` (or `0`
986
- * if not found, in which case the handler returns `null` instead).
987
- */
988
- interface FetchResult {
989
- rows: EntityRow | EntityRow[];
990
- total: number;
991
- }
992
- /**
993
- * If effect - conditional effect execution.
994
- * Uses SExpr to allow deeply nested conditionals.
995
- * @example ['if', ['>', '@entity.health', 0], ['emit', 'ALIVE'], ['emit', 'DEAD']]
996
- */
997
- type IfEffect = ['if', Expression, SExpr] | ['if', Expression, SExpr, SExpr];
998
- /**
999
- * When effect - conditional effect similar to if but without else.
1000
- * Uses SExpr to allow deeply nested conditionals.
1001
- * @example ['when', ['>', '@entity.health', 0], ['emit', 'ALIVE']]
1002
- */
1003
- type WhenEffect = ['when', Expression, SExpr];
1004
- /**
1005
- * Let effect - creates local bindings for effects.
1006
- * Uses SExpr to allow deeply nested conditionals.
1007
- * @example ['let', ['temp', ['get', '@payload.value']], ['set', '@entity.value', 'temp']]
1008
- */
1009
- type LetEffect = ['let', [string, unknown][], ...SExpr[]];
1010
- /**
1011
- * Log effect - logs a message for debugging.
1012
- * @example ['log', 'User created:', '@entity.name']
1013
- */
1014
- type LogEffect = ['log', ...unknown[]];
1015
- /**
1016
- * Wait effect - delays execution.
1017
- * @example ['wait', 1000] - wait 1 second
1018
- */
1019
- type WaitEffect = ['wait', number];
1020
- /**
1021
- * Ref effect - creates a reactive entity subscription.
1022
- * Returns a reactive reference that auto-updates when the entity changes.
1023
- * @example ['ref', '@entity.health'] - reactive subscription to health
1024
- * @example ['ref', 'User', { id: '@payload.userId' }] - reactive ref to specific user
1025
- */
1026
- type RefEffect = ['ref', string] | ['ref', string, FetchOptions];
1027
- /**
1028
- * Deref effect - snapshot read of an entity value.
1029
- * Returns the current value without subscribing to changes.
1030
- * @example ['deref', '@entity.health'] - read current health value
1031
- * @example ['deref', 'User', { id: '@payload.userId' }] - read specific user snapshot
1032
- */
1033
- type DerefEffect = ['deref', string] | ['deref', string, FetchOptions];
1034
- /**
1035
- * Swap! effect - atomic compare-and-swap on an entity field.
1036
- * Only updates if the current value matches the expected value.
1037
- * @example ['swap!', '@entity.health', ['fn', ['old'], ['-', 'old', '@payload.damage']]]
1038
- * @example ['swap!', '@entity.counter', ['+', '@entity.counter', 1]]
1039
- */
1040
- type SwapEffect = ['swap!', string, SExpr];
1041
- /**
1042
- * Options accepted by `watch` effects. Mirrors what the runtime reads when
1043
- * registering the change callback: `debounce` and the trailing `emit:` map.
1044
- */
1045
- interface WatchOptions {
1046
- /** Debounce duration in milliseconds */
1047
- debounce?: number;
1048
- /** Lifecycle events to emit on update / failure */
1049
- emit?: {
1050
- on_message?: string;
1051
- failure?: string;
1052
- };
1053
- }
1054
- /**
1055
- * Watch effect - registers a callback for entity changes.
1056
- * Emits an event whenever the watched binding changes.
1057
- * @example ['watch', '@entity.health', 'HEALTH_CHANGED']
1058
- * @example ['watch', '@entity.status', 'STATUS_UPDATED', { debounce: 100 }]
1059
- */
1060
- type WatchEffect = ['watch', string, string] | ['watch', string, string, WatchOptions];
1061
- /**
1062
- * Atomic effect - groups multiple effects into an atomic transaction.
1063
- * All effects either succeed together or are rolled back.
1064
- * @example ['atomic', ['set', '@entity.x', 10], ['set', '@entity.y', 20]]
1065
- * @example ['atomic', ['persist', 'update', 'User', { balance: 100 }], ['emit', 'BALANCE_UPDATED']]
1066
- */
1067
- type AtomicEffect = ['atomic', ...SExpr[]];
1068
- /**
1069
- * One layer in an NN architecture description. The set of valid layer kinds
1070
- * lives in `almadar-std/modules/nn`; here we keep the wire shape generic
1071
- * enough for the cross-package runtime + Python bridge to round-trip.
1072
- */
1073
- interface NnLayer {
1074
- type: string;
1075
- [key: string]: string | number | boolean | number[] | string[] | undefined;
1076
- }
1077
- /**
1078
- * Hyperparameters for `train` and `evaluate`. Recursive to allow nested
1079
- * optimizer / scheduler config blocks without falling back to `unknown`.
1080
- */
1081
- interface NnConfig {
1082
- [key: string]: string | number | boolean | string[] | number[] | NnConfig | undefined;
1083
- }
1084
- /**
1085
- * Forward-pass config: `input` is a binding string (`@payload.input`), and
1086
- * `on-complete` names the event to fire when the prediction lands.
1087
- */
1088
- interface ForwardConfig {
1089
- architecture: NnLayer[];
1090
- input: string;
1091
- 'on-complete'?: string;
1092
- config?: NnConfig;
1093
- }
1094
- /**
1095
- * Training-loop config. `dataset` is a binding string referencing the rows
1096
- * to train on. Optimizer / loss / scheduler land inside `config`.
1097
- */
1098
- interface TrainConfig {
1099
- architecture: NnLayer[];
1100
- dataset: string;
1101
- config?: NnConfig;
1102
- 'on-complete'?: string;
1103
- }
1104
- /**
1105
- * Evaluation config. `metrics` lists named metrics the Python backend
1106
- * computes (`accuracy`, `precision`, ...).
1107
- */
1108
- interface EvaluateConfig {
1109
- architecture: NnLayer[];
1110
- dataset: string;
1111
- metrics: string[];
1112
- config?: NnConfig;
1113
- 'on-complete'?: string;
1114
- }
1115
- /**
1116
- * Forward effect - runs a neural network forward pass (Python backend).
1117
- * @example ['forward', 'primary', { architecture: [...], input: '@payload.input', 'on-complete': 'PREDICTION_READY' }]
1118
- */
1119
- type ForwardEffect = ['forward', string, ForwardConfig];
1120
- /**
1121
- * Train effect - runs a training loop (Python backend).
1122
- * @example ['train', { architecture: [...], dataset: '@entity.data', config: { epochs: 10 }, 'on-complete': 'TRAINING_DONE' }]
1123
- */
1124
- type TrainEffect = ['train', TrainConfig];
1125
- /**
1126
- * Evaluate effect - runs model evaluation (Python backend).
1127
- * @example ['evaluate', { architecture: [...], dataset: '@entity.testData', metrics: ['accuracy'], 'on-complete': 'EVAL_DONE' }]
1128
- */
1129
- type EvaluateEffect = ['evaluate', EvaluateConfig];
1130
- /**
1131
- * Checkpoint save effect - saves model weights.
1132
- * @example ['checkpoint/save', '/path/to/model.pt', '@entity.weights']
1133
- */
1134
- type CheckpointSaveEffect = ['checkpoint/save', string, unknown];
1135
- /**
1136
- * Checkpoint load effect - loads model weights.
1137
- * @example ['checkpoint/load', '/path/to/model.pt']
1138
- */
1139
- type CheckpointLoadEffect = ['checkpoint/load', string];
1140
- /**
1141
- * Agent effect - invokes an agent/* operator.
1142
- * Covers all 22 operators in the std-agent category.
1143
- * @example ['agent/memorize', 'use data-grid for tables', 'preference']
1144
- * @example ['agent/recall', 'user preferences']
1145
- * @example ['agent/generate', 'Summarize this schema']
1146
- */
1147
- type AgentEffect = [`agent/${string}`, ...SExpr[]];
1148
- /**
1149
- * OS effect - invokes an os/* operator.
1150
- *
1151
- * Covers reactive subscriptions to OS / network resources:
1152
- * - `os/watch-http`, `os/watch-ws`, `os/watch-sse` — long-lived streams
1153
- * that fire `on_message` / `failure` events through a trailing
1154
- * `EmitConfig` block (see `EmitConfig` for the supported keys).
1155
- * - `os/read-file`, `os/exec`, etc. — one-shot OS operations.
1156
- *
1157
- * @example ['os/watch-http', 'wss://push.example.com', { emit: { on_message: 'PUSH_RECEIVED', failure: 'PUSH_DISCONNECTED' } }]
1158
- * @example ['os/read-file', '/etc/hosts']
1159
- */
1160
- type OsEffect = [`os/${string}`, ...SExpr[]];
1161
- /**
1162
- * Browser effect - invokes a browser/* device operator (client host path).
1163
- * User-initiated, async, resolves via the standard trailing emit envelope.
1164
- * Concrete operators (browser/open-file-picker, browser/clipboard-read,
1165
- * browser/clipboard-write, browser/geolocation-current) and their arity /
1166
- * payload shapes live in @almadar/std BROWSER_OPERATORS.
1167
- * @example ['browser/open-file-picker', { multiple: false }, { emit: { success: 'FILES_PICKED', failure: 'PICK_CANCELLED' } }]
1168
- */
1169
- type BrowserEffect = [`browser/${string}`, ...SExpr[]];
1170
- /**
1171
- * LLM effect - invokes an llm/* operator (agent path).
1172
- * @example ['llm/generate', '@entity.request', { emit: { success: 'PLANNED', failure: 'PLAN_FAILED' } }]
1173
- */
1174
- type LlmEffect = [`llm/${string}`, ...SExpr[]];
1175
- /**
1176
- * Behavior effect - invokes a behavior/* operator (agent path).
1177
- * @example ['behavior/instantiate', '@entity.plan', { emit: { failure: 'BUILD_FAILED' } }]
1178
- */
1179
- type BehaviorEffect = [`behavior/${string}`, ...SExpr[]];
1180
- /**
1181
- * Validate effect - invokes a validate/* operator (agent path).
1182
- * @example ['validate/validate', '@entity.schema', { emit: { failure: 'INVALID' } }]
1183
- */
1184
- type ValidateEffect = [`validate/${string}`, ...SExpr[]];
1185
- /**
1186
- * Remaining agent-path operator effects: session/* (workspace session ops),
1187
- * compose/* (schema composition), trace/* (trace emission), memory/*
1188
- * (agent memory), application/* (app lifecycle). Expression-only namespaces
1189
- * (array/, math/, object/, str/, …) are deliberately NOT effect heads.
1190
- * @example ['session/write-spec', '@entity.spec']
1191
- * @example ['compose/compose-all', { emit: { failure: 'COMPOSE_FAILED' } }]
1192
- */
1193
- type SessionEffect = [`session/${string}`, ...SExpr[]];
1194
- type ComposeEffect = [`compose/${string}`, ...SExpr[]];
1195
- type TraceEffect = [`trace/${string}`, ...SExpr[]];
1196
- type MemoryEffect = [`memory/${string}`, ...SExpr[]];
1197
- type ApplicationEffect = [`application/${string}`, ...SExpr[]];
1198
- /**
1199
- * Async delay effect - wait then execute effects.
1200
- * @example ['async/delay', 2000, ['emit', 'TIMEOUT']]
1201
- */
1202
- type AsyncDelayEffect = ['async/delay', number | string, ...Effect[]];
1203
- /**
1204
- * Async debounce effect - debounce then execute effect.
1205
- * @example ['async/debounce', 300, ['emit', 'SEARCH_COMPLETE']]
1206
- * @example ['async/debounce', '@entity.debounceMs', ['emit', 'SEARCH_COMPLETE']]
1207
- */
1208
- type AsyncDebounceEffect = ['async/debounce', number | string, SExpr];
1209
- /**
1210
- * Async throttle effect - throttle then execute effect.
1211
- * @example ['async/throttle', 100, ['emit', 'SCROLL_HANDLED']]
1212
- * @example ['async/throttle', '@entity.throttleMs', ['emit', 'SCROLL_HANDLED']]
1213
- */
1214
- type AsyncThrottleEffect = ['async/throttle', number | string, SExpr];
1215
- /**
1216
- * Async interval effect - execute effect at intervals.
1217
- * @example ['async/interval', 1000, ['emit', 'TICK']]
1218
- * @example ['async/interval', '@entity.intervalMs', ['emit', 'POLL_TICK']]
1219
- */
1220
- type AsyncIntervalEffect = ['async/interval', number | string, SExpr];
1221
- /**
1222
- * Async race effect - first effect to complete wins.
1223
- * @example ['async/race', ['call', 'api1'], ['call', 'api2']]
1224
- */
1225
- type AsyncRaceEffect = ['async/race', ...Effect[]];
1226
- /**
1227
- * Async all effect - wait for all effects to complete.
1228
- * @example ['async/all', ['call', 'api1'], ['call', 'api2']]
1229
- */
1230
- type AsyncAllEffect = ['async/all', ...Effect[]];
1231
- /**
1232
- * Async sequence effect - execute effects in sequence.
1233
- * @example ['async/sequence', ['call', 'validate'], ['call', 'save']]
1234
- */
1235
- type AsyncSequenceEffect = ['async/sequence', ...Effect[]];
1236
- /**
1237
- * Union of all typed effects.
1238
- * Provides compile-time validation for common effect types.
1239
- */
1240
- type TypedEffect = RenderUIEffect | NavigateEffect | EmitEffect | SetEffect | PersistEffect | CallServiceEffect | SpawnEffect | DespawnEffect | DoEffect | NotifyEffect | FetchEffect | IfEffect | WhenEffect | LetEffect | LogEffect | WaitEffect | RefEffect | DerefEffect | SwapEffect | WatchEffect | AtomicEffect | AsyncDelayEffect | AsyncDebounceEffect | AsyncThrottleEffect | AsyncIntervalEffect | AsyncRaceEffect | AsyncAllEffect | AsyncSequenceEffect | ForwardEffect | TrainEffect | EvaluateEffect | CheckpointSaveEffect | CheckpointLoadEffect | AgentEffect | OsEffect | BrowserEffect | LlmEffect | BehaviorEffect | ValidateEffect | SessionEffect | ComposeEffect | TraceEffect | MemoryEffect | ApplicationEffect;
1241
- /**
1242
- * Effect type - typed S-expression format.
1243
- *
1244
- * Effects are strongly typed tuples that enforce:
1245
- * - Valid effect operators (render-ui, emit, set, persist, navigate, call-service)
1246
- * - Valid UISlots for render-ui
1247
- * - Valid PatternTypes and props for render-ui
1248
- * - Correct argument types for each effect
1249
- *
1250
- * Available typed effects:
1251
- * - RenderUIEffect: ['render-ui', UISlot, PatternConfig]
1252
- * - NavigateEffect: ['navigate', path] or ['navigate', path, params]
1253
- * - EmitEffect: ['emit', eventName] or ['emit', eventName, payload]
1254
- * - SetEffect: ['set', binding, value]
1255
- * - PersistEffect: ['persist', operation, entity, data?]
1256
- * - CallServiceEffect: ['call-service', serviceName, config]
1257
- *
1258
- * @example
1259
- * ["set", "@entity.health", 100]
1260
- * ["emit", "PLAYER_DIED", { "playerId": "@entity.id" }]
1261
- * ["render-ui", "main", { "patternType": "entity-table", "columns": ["name"] }]
1262
- * ["call-service", "WeatherAPI", { "action": "getWeather", "onSuccess": "OK" }]
1263
- * ["navigate", "/tasks"]
1264
- * ["persist", "create", "Task", { "title": "@payload.title" }]
1265
- */
1266
- type Effect = TypedEffect;
1267
- /**
1268
- * Schema for Effect - validates S-expression format
1269
- */
1270
- declare const EffectSchema: z.ZodEffects<z.ZodArray<z.ZodUnknown, "many">, unknown[], unknown[]>;
1271
- type EffectInput = z.input<typeof EffectSchema>;
1272
- /**
1273
- * Type guard to check if a value is a valid Effect (S-expression).
1274
- *
1275
- * Validates that a value conforms to the Effect structure. Effects are
1276
- * represented as arrays where the first element is a string (effect type)
1277
- * and subsequent elements are parameters. Used for runtime validation
1278
- * of effect structures.
1279
- *
1280
- * @param {unknown} value - Value to check
1281
- * @returns {boolean} True if value is a valid Effect, false otherwise
1282
- *
1283
- * @example
1284
- * isEffect(['set', '@entity.health', 100]); // returns true
1285
- * isEffect('not-an-effect'); // returns false
1286
- * isEffect([]); // returns false
1287
- */
1288
- declare function isEffect(value: unknown): value is Effect;
1289
- /**
1290
- * Alias for isEffect (for clarity when working with S-expressions)
1291
- */
1292
- declare const isSExprEffect: typeof isEffect;
1293
- /**
1294
- * Creates a set effect for state updates.
1295
- *
1296
- * Generates an effect that sets a binding to a value. Used in state
1297
- * machine transitions to update entity fields, UI state, or other
1298
- * mutable data.
1299
- *
1300
- * @param {string} binding - Target binding (e.g., '@entity.health')
1301
- * @param {SExpr} value - Value to set (can be literal or expression)
1302
- * @returns {Effect} Set effect array
1303
- *
1304
- * @example
1305
- * set('@entity.health', 100); // returns ["set", "@entity.health", 100]
1306
- * set('@state.loading', false); // returns ["set", "@state.loading", false]
1307
- */
1308
- declare function set(binding: string, value: SExpr): Effect;
1309
- /**
1310
- * Creates an emit effect for event dispatching.
1311
- *
1312
- * Generates an effect that emits an event with optional payload.
1313
- * Used in state machine transitions to trigger events that can be
1314
- * handled by other traits, services, or external systems.
1315
- *
1316
- * @param {string} event - Event name to emit
1317
- * @param {EventPayload} [payload] - Optional event payload
1318
- * @returns {Effect} Emit effect array
1319
- *
1320
- * @example
1321
- * emit('PLAYER_DIED', { playerId: '@entity.id' }); // returns ["emit", "PLAYER_DIED", { playerId: "@entity.id" }]
1322
- * emit('GAME_STARTED'); // returns ["emit", "GAME_STARTED"]
1323
- */
1324
- declare function emit(event: string, payload?: EventPayload): Effect;
1325
- /**
1326
- * Creates a navigation effect for page routing.
1327
- *
1328
- * Generates an effect that navigates to a specified path with optional
1329
- * parameters. Used in state machine transitions to change pages or
1330
- * update URL parameters.
1331
- *
1332
- * @param {string} path - Target path (e.g., '/tasks')
1333
- * @param {Record<string, string>} [params] - Optional URL parameters
1334
- * @returns {NavigateEffect} Navigation effect array
1335
- *
1336
- * @example
1337
- * navigate('/tasks'); // returns ["navigate", "/tasks"]
1338
- * navigate('/user', { id: '123' }); // returns ["navigate", "/user", { id: "123" }]
1339
- */
1340
- declare function navigate(path: string): NavigateEffect;
1341
- declare function navigate(path: string, params: Record<string, string>): NavigateEffect;
1342
- /**
1343
- * Create a render-ui effect
1344
- * @example ["render-ui", "main", { "patternType": "entity-table", "columns": ["name"] }]
1345
- */
1346
- declare function renderUI(target: UISlot, pattern: AnyPatternConfig): RenderUIEffect;
1347
- declare function renderUI(target: UISlot, pattern: AnyPatternConfig, props: ResolvedPatternProps): RenderUIEffect;
1348
- /**
1349
- * Create a persist effect
1350
- * @example ["persist", "create", "Task", { "title": "@payload.title" }]
1351
- */
1352
- declare function persist(action: 'create' | 'update', entity: string, data: PersistData): PersistEffect;
1353
- declare function persist(action: 'delete' | 'clear', entity: string, data?: PersistData): PersistEffect;
1354
- /**
1355
- * Create a call-service effect
1356
- * @example ["call-service", "stripe", { "service": "stripe", "action": "charge", "onSuccess": "OK", "onError": "ERR" }]
1357
- */
1358
- declare function callService(serviceName: string, config: CallServiceConfig): CallServiceEffect;
1359
- /**
1360
- * Create a spawn effect (games)
1361
- * @example ["spawn", "Bullet", { "x": "@entity.x", "y": "@entity.y" }]
1362
- */
1363
- declare function spawn(entity: string): SpawnEffect;
1364
- declare function spawn(entity: string, initialState: EntityRow): SpawnEffect;
1365
- /**
1366
- * Create a despawn effect (games)
1367
- * @example ["despawn", "@entity.id"]
1368
- */
1369
- declare function despawn(entityId: string): DespawnEffect;
1370
- /**
1371
- * Create a do effect (multiple effects)
1372
- * @example ["do", ["set", "@entity.x", 0], ["set", "@entity.y", 0]]
1373
- */
1374
- declare function doEffects(...effects: SExpr[]): DoEffect;
1375
- /**
1376
- * Create a notify effect
1377
- * @example ["notify", "in_app", "Task created successfully"]
1378
- */
1379
- declare function notify(channel: 'email' | 'push' | 'sms' | 'in_app', message: string): NotifyEffect;
1380
- declare function notify(channel: 'email' | 'push' | 'sms' | 'in_app', message: string, recipient: string): NotifyEffect;
1381
- /**
1382
- * Create a ref effect (reactive entity subscription).
1383
- *
1384
- * @param {string} binding - Binding or entity name to subscribe to
1385
- * @param {FetchOptions} [selector] - Optional selector for specific entity
1386
- * @returns {RefEffect} Ref effect array
1387
- *
1388
- * @example
1389
- * ref('@entity.health'); // returns ["ref", "@entity.health"]
1390
- * ref('User', { id: '@payload.userId' }); // returns ["ref", "User", { id: "@payload.userId" }]
1391
- */
1392
- declare function ref(binding: string): RefEffect;
1393
- declare function ref(binding: string, selector: FetchOptions): RefEffect;
1394
- /**
1395
- * Create a deref effect (snapshot read).
1396
- *
1397
- * @param {string} binding - Binding or entity name to read
1398
- * @param {FetchOptions} [selector] - Optional selector for specific entity
1399
- * @returns {DerefEffect} Deref effect array
1400
- *
1401
- * @example
1402
- * deref('@entity.health'); // returns ["deref", "@entity.health"]
1403
- * deref('User', { id: '@payload.userId' }); // returns ["deref", "User", { id: "@payload.userId" }]
1404
- */
1405
- declare function deref(binding: string): DerefEffect;
1406
- declare function deref(binding: string, selector: FetchOptions): DerefEffect;
1407
- /**
1408
- * Create a swap! effect (atomic compare-and-swap).
1409
- *
1410
- * @param {string} binding - Binding to atomically update
1411
- * @param {SExpr} transform - Transformation expression applied to the current value
1412
- * @returns {SwapEffect} Swap effect array
1413
- *
1414
- * @example
1415
- * swap('@entity.counter', ['+', '@entity.counter', 1]);
1416
- * // returns ["swap!", "@entity.counter", ["+", "@entity.counter", 1]]
1417
- */
1418
- declare function swap(binding: string, transform: SExpr): SwapEffect;
1419
- /**
1420
- * Create a watch effect (entity change callback).
1421
- *
1422
- * @example
1423
- * watch('@entity.health', 'HEALTH_CHANGED');
1424
- * watch('@entity.status', 'STATUS_UPDATED', { debounce: 100 });
1425
- */
1426
- declare function watch(binding: string, event: string): WatchEffect;
1427
- declare function watch(binding: string, event: string, options: WatchOptions): WatchEffect;
1428
- /**
1429
- * Create an atomic effect (transaction group).
1430
- *
1431
- * @param {...SExpr[]} effects - Effects to execute atomically
1432
- * @returns {AtomicEffect} Atomic effect array
1433
- *
1434
- * @example
1435
- * atomic(['set', '@entity.x', 10], ['set', '@entity.y', 20]);
1436
- * // returns ["atomic", ["set", "@entity.x", 10], ["set", "@entity.y", 20]]
1437
- */
1438
- declare function atomic(...effects: SExpr[]): AtomicEffect;
1439
- /** Resolved pattern props for render-ui effects at runtime. Recursive for nested pattern configs. */
1440
- interface ResolvedPatternProps {
1441
- [prop: string]: string | number | boolean | null | undefined | ResolvedPatternProps | ResolvedPatternProps[];
1442
- }
1443
- /** A node in a render-ui effect tree. */
1444
- interface RenderUINode {
1445
- type: string;
1446
- props?: ResolvedPatternProps;
1447
- /** Static child nodes and/or dynamic-collection map entries. A
1448
- * {@link RenderChildrenMap} entry expands at render time into resolved
1449
- * `RenderUINode`s, so components always receive a flat, fully-resolved list. */
1450
- children?: Array<RenderUINode | RenderChildrenMap>;
1451
- content?: string;
1452
- entity?: string;
1453
- renderItem?: RenderUINode;
1454
- }
1455
-
1456
5
  /**
1457
6
  * Represents a state in the state machine
1458
7
  */
1459
- interface State {
8
+ type State = {
1460
9
  /** State name (unique identifier) */
1461
10
  name: string;
1462
11
  /** Whether this is the initial state */
@@ -1471,7 +20,7 @@ interface State {
1471
20
  onEntry?: string[];
1472
21
  /** Effect names to run on exit */
1473
22
  onExit?: string[];
1474
- }
23
+ };
1475
24
  declare const StateSchema: z.ZodObject<{
1476
25
  name: z.ZodString;
1477
26
  isInitial: z.ZodOptional<z.ZodBoolean>;
@@ -1500,7 +49,7 @@ declare const StateSchema: z.ZodObject<{
1500
49
  /**
1501
50
  * Payload field definition for events
1502
51
  */
1503
- interface PayloadField {
52
+ type PayloadField = {
1504
53
  name: string;
1505
54
  /**
1506
55
  * Field type. Mirrors the Rust validator's acceptance: any non-empty
@@ -1513,12 +62,12 @@ interface PayloadField {
1513
62
  required?: boolean;
1514
63
  /** Structured property schema for object-typed payload fields (recursive). */
1515
64
  properties?: ReadonlyArray<PayloadField>;
1516
- }
65
+ };
1517
66
  declare const PayloadFieldSchema: z.ZodType<PayloadField>;
1518
67
  /**
1519
68
  * Represents an event that can trigger transitions
1520
69
  */
1521
- interface Event {
70
+ type Event = {
1522
71
  /** Event key (UPPER_SNAKE_CASE) */
1523
72
  key: string;
1524
73
  /** V4 dual-carry id sibling of `key` — optional until the Phase-7 flip. */
@@ -1538,7 +87,7 @@ interface Event {
1538
87
  classification?: "domain" | "system";
1539
88
  /** Semantic role of this event (optional, for analysis) */
1540
89
  semanticRole?: string;
1541
- }
90
+ };
1542
91
  declare const EventSchema: z.ZodObject<{
1543
92
  key: z.ZodString;
1544
93
  id: z.ZodOptional<z.ZodEffects<z.ZodString, EventId, string>>;
@@ -1581,12 +130,12 @@ declare const EventSchema: z.ZodObject<{
1581
130
  * description: "Check if entity has health remaining"
1582
131
  * }
1583
132
  */
1584
- interface Guard {
133
+ type Guard = {
1585
134
  name: string;
1586
135
  /** Guard expression - S-expression array only */
1587
136
  expression: Expression;
1588
137
  description?: string;
1589
- }
138
+ };
1590
139
  declare const GuardSchema: z.ZodObject<{
1591
140
  name: z.ZodString;
1592
141
  expression: z.ZodType<SExpr, z.ZodTypeDef, SExpr>;
@@ -1616,7 +165,7 @@ declare const GuardSchema: z.ZodObject<{
1616
165
  * ]
1617
166
  * }
1618
167
  */
1619
- interface Transition {
168
+ type Transition = {
1620
169
  /** Source state name */
1621
170
  from: string;
1622
171
  /** Target state name */
@@ -1631,7 +180,7 @@ interface Transition {
1631
180
  effects?: Effect[];
1632
181
  /** Description */
1633
182
  description?: string | null;
1634
- }
183
+ };
1635
184
  declare const TransitionSchema: z.ZodObject<{
1636
185
  from: z.ZodString;
1637
186
  to: z.ZodString;
@@ -1660,7 +209,7 @@ declare const TransitionSchema: z.ZodObject<{
1660
209
  /**
1661
210
  * Complete state machine definition
1662
211
  */
1663
- interface StateMachine {
212
+ type StateMachine = {
1664
213
  /** All states in the machine */
1665
214
  states: State[];
1666
215
  /** All events that can be triggered */
@@ -1669,7 +218,7 @@ interface StateMachine {
1669
218
  transitions: Transition[];
1670
219
  /** Named guard definitions */
1671
220
  guards?: Guard[];
1672
- }
221
+ };
1673
222
  declare const StateMachineSchema: z.ZodObject<{
1674
223
  states: z.ZodArray<z.ZodObject<{
1675
224
  name: z.ZodString;
@@ -1865,9 +414,9 @@ declare function isCircuitEvent(event: string): boolean;
1865
414
  * via `@config.<key>` bindings.
1866
415
  */
1867
416
  type TraitConfigValue = string | number | boolean | null | ReadonlyArray<TraitConfigValue> | TraitConfigObject;
1868
- interface TraitConfigObject {
417
+ type TraitConfigObject = {
1869
418
  readonly [key: string]: TraitConfigValue;
1870
- }
419
+ };
1871
420
  type TraitConfig = TraitConfigObject;
1872
421
  /** Zod schema for TraitConfig. Recursive via z.lazy to allow nested structures. */
1873
422
  declare const TraitConfigValueSchema: z.ZodType<TraitConfigValue>;
@@ -1947,7 +496,7 @@ declare const REFERENCE_CONFIG_TYPES: readonly ["entity", "trait", "event"];
1947
496
  type ReferenceConfigType = (typeof REFERENCE_CONFIG_TYPES)[number];
1948
497
  /** True when a config field's `type` marks its value as an entity/trait/event reference. */
1949
498
  declare function isReferenceConfigType(type: string): type is ReferenceConfigType;
1950
- interface ConfigFieldDeclaration {
499
+ type ConfigFieldDeclaration = {
1951
500
  readonly type: string;
1952
501
  readonly default?: TraitConfigValue;
1953
502
  /**
@@ -1973,14 +522,14 @@ interface ConfigFieldDeclaration {
1973
522
  readonly items?: ConfigFieldItemsDeclaration;
1974
523
  /** Structured property schema for object-typed config fields (no items wrapper). */
1975
524
  readonly properties?: Readonly<Record<string, TraitEntityField>>;
1976
- }
1977
- interface ConfigFieldItemsDeclaration {
525
+ };
526
+ type ConfigFieldItemsDeclaration = {
1978
527
  readonly type?: string;
1979
528
  /** Absent for arrays of scalars (`items: { type: "string" }`). */
1980
529
  readonly properties?: Readonly<Record<string, TraitEntityField>>;
1981
530
  /** Nested per-item schema for arrays of arrays (recursive). */
1982
531
  readonly items?: ConfigFieldItemsDeclaration;
1983
- }
532
+ };
1984
533
  declare const ConfigFieldDeclarationSchema: z.ZodType<ConfigFieldDeclaration>;
1985
534
  /**
1986
535
  * Map of declared config fields keyed by name. Lives on `Trait.config`
@@ -2001,22 +550,23 @@ type TraitFieldType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'obje
2001
550
  /**
2002
551
  * Simplified field for trait data entities
2003
552
  */
2004
- interface TraitEntityField {
553
+ type TraitEntityField = {
2005
554
  name: string;
2006
555
  type: TraitFieldType;
2007
556
  required?: boolean;
2008
- default?: unknown;
557
+ /** Field default parsed from `.orb` — always a JSON-shaped value. */
558
+ default?: TraitConfigValue;
2009
559
  values?: string[];
2010
560
  /** Structured per-item schema for array-of-object fields (recursive). */
2011
561
  items?: ConfigFieldItemsDeclaration;
2012
562
  /** Structured property schema for object-typed entity fields. */
2013
563
  properties?: Readonly<Record<string, TraitEntityField>>;
2014
- }
564
+ };
2015
565
  declare const TraitEntityFieldSchema: z.ZodType<TraitEntityField>;
2016
566
  /**
2017
567
  * Simplified data entity for traits
2018
568
  */
2019
- interface TraitDataEntity {
569
+ type TraitDataEntity = {
2020
570
  name: string;
2021
571
  collection?: string;
2022
572
  fields: TraitEntityField[];
@@ -2025,7 +575,7 @@ interface TraitDataEntity {
2025
575
  runtime?: boolean;
2026
576
  singleton?: boolean;
2027
577
  pages?: string[];
2028
- }
578
+ };
2029
579
  declare const TraitDataEntitySchema: z.ZodObject<{
2030
580
  name: z.ZodString;
2031
581
  collection: z.ZodOptional<z.ZodString>;
@@ -2059,7 +609,7 @@ declare const TraitDataEntitySchema: z.ZodObject<{
2059
609
  * Guards can be legacy strings or S-expressions.
2060
610
  * Effects can be typed Effect objects or S-expressions.
2061
611
  */
2062
- interface TraitTick {
612
+ type TraitTick = {
2063
613
  name: string;
2064
614
  description?: string;
2065
615
  priority?: number;
@@ -2080,7 +630,7 @@ interface TraitTick {
2080
630
  emits?: string[];
2081
631
  /** V4 dual-carry id sibling of `emits` — optional until the Phase-7 flip. */
2082
632
  emitIds?: EventId[];
2083
- }
633
+ };
2084
634
  declare const TraitTickSchema: z.ZodObject<{
2085
635
  name: z.ZodString;
2086
636
  description: z.ZodOptional<z.ZodString>;
@@ -2129,7 +679,7 @@ declare const EventScopeSchema: z.ZodEnum<["internal", "external"]>;
2129
679
  * Payload field definition for events.
2130
680
  * Defines the structure of data carried by events.
2131
681
  */
2132
- interface EventPayloadField {
682
+ type EventPayloadField = {
2133
683
  /** Field name */
2134
684
  name: string;
2135
685
  /**
@@ -2152,13 +702,13 @@ interface EventPayloadField {
2152
702
  entityType?: string;
2153
703
  /** Structured property schema for object-typed payload fields (recursive). */
2154
704
  properties?: ReadonlyArray<EventPayloadField>;
2155
- }
705
+ };
2156
706
  declare const EventPayloadFieldSchema: z.ZodType<EventPayloadField>;
2157
707
  /**
2158
708
  * Event contract for events a trait emits.
2159
709
  * Declares the event name, scope, and payload schema.
2160
710
  */
2161
- interface TraitEventContract {
711
+ type TraitEventContract = {
2162
712
  /** Event name (UPPER_SNAKE_CASE) */
2163
713
  event: string;
2164
714
  /** V4 dual-carry id sibling of `event` — optional until the Phase-7 flip. */
@@ -2180,7 +730,7 @@ interface TraitEventContract {
2180
730
  * - 'external': Exposed for cross-orbital communication
2181
731
  */
2182
732
  scope?: EventScope;
2183
- }
733
+ };
2184
734
  /**
2185
735
  * `@config.<knob>` is the only legal reference form for an emit/listen
2186
736
  * event name (Option B — the declared event name resolves to a
@@ -2313,7 +863,7 @@ declare const ListenSourceSchema: z.ZodUnion<[z.ZodObject<{
2313
863
  traitId?: string | undefined;
2314
864
  orbitalId?: string | undefined;
2315
865
  }>]>;
2316
- interface TraitEventListener {
866
+ type TraitEventListener = {
2317
867
  /** Event key to listen for (bare event name, no source prefix in the new shape) */
2318
868
  event: string;
2319
869
  /** V4 dual-carry id sibling of `event` — optional until the Phase-7 flip. */
@@ -2343,7 +893,7 @@ interface TraitEventListener {
2343
893
  * a local payload declaration rather than a bus subscription.
2344
894
  */
2345
895
  source?: ListenSource;
2346
- }
896
+ };
2347
897
  declare const TraitEventListenerSchema: z.ZodObject<{
2348
898
  event: z.ZodString;
2349
899
  eventId: z.ZodOptional<z.ZodEffects<z.ZodString, EventId, string>>;
@@ -2444,11 +994,11 @@ declare const TraitEventListenerSchema: z.ZodObject<{
2444
994
  /**
2445
995
  * Field required by a trait from its linkedEntity
2446
996
  */
2447
- interface RequiredField {
997
+ type RequiredField = {
2448
998
  name: string;
2449
999
  type: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'timestamp' | 'datetime' | 'enum';
2450
1000
  description?: string;
2451
- }
1001
+ };
2452
1002
  declare const RequiredFieldSchema: z.ZodObject<{
2453
1003
  name: z.ZodString;
2454
1004
  type: z.ZodEnum<["string", "number", "boolean", "date", "array", "object", "timestamp", "datetime", "enum"]>;
@@ -2470,7 +1020,7 @@ declare const RequiredFieldSchema: z.ZodObject<{
2470
1020
  * identifier-substitution pass uses these arguments to rewrite the
2471
1021
  * inlined trait clone before lowering.
2472
1022
  */
2473
- interface TraitReference {
1023
+ type TraitReference = {
2474
1024
  ref: string;
2475
1025
  /** V4 dual-carry id sibling of `ref` — optional until the Phase-7 flip. */
2476
1026
  refId?: TraitId;
@@ -2558,8 +1108,8 @@ interface TraitReference {
2558
1108
  * }
2559
1109
  * ```
2560
1110
  */
2561
- effects?: Record<string, unknown[]>;
2562
- }
1111
+ effects?: Record<string, SExpr[]>;
1112
+ };
2563
1113
  declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2564
1114
  ref: z.ZodString;
2565
1115
  refId: z.ZodOptional<z.ZodEffects<z.ZodString, TraitId, string>>;
@@ -2575,7 +1125,7 @@ declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2575
1125
  appliesTo: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2576
1126
  listens: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
2577
1127
  emitsScope: z.ZodOptional<z.ZodEnum<["internal", "external"]>>;
2578
- effects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown, "many">>>;
1128
+ effects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodType<SExpr, z.ZodTypeDef, SExpr>, "many">>>;
2579
1129
  }, "strip", z.ZodTypeAny, {
2580
1130
  ref: string;
2581
1131
  id?: TraitId | undefined;
@@ -2584,7 +1134,7 @@ declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2584
1134
  fields?: Record<string, string> | undefined;
2585
1135
  config?: Record<string, TraitConfigValue | ConfigFieldDeclaration> | undefined;
2586
1136
  events?: Record<string, string> | undefined;
2587
- effects?: Record<string, unknown[]> | undefined;
1137
+ effects?: Record<string, SExpr[]> | undefined;
2588
1138
  refId?: TraitId | undefined;
2589
1139
  appliesTo?: string[] | undefined;
2590
1140
  linkedEntity?: string | undefined;
@@ -2600,7 +1150,7 @@ declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2600
1150
  fields?: Record<string, string> | undefined;
2601
1151
  config?: Record<string, TraitConfigValue | ConfigFieldDeclaration> | undefined;
2602
1152
  events?: Record<string, string> | undefined;
2603
- effects?: Record<string, unknown[]> | undefined;
1153
+ effects?: Record<string, SExpr[]> | undefined;
2604
1154
  refId?: string | undefined;
2605
1155
  appliesTo?: string[] | undefined;
2606
1156
  linkedEntity?: string | undefined;
@@ -2616,7 +1166,7 @@ declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2616
1166
  fields?: Record<string, string> | undefined;
2617
1167
  config?: Record<string, TraitConfigValue | ConfigFieldDeclaration> | undefined;
2618
1168
  events?: Record<string, string> | undefined;
2619
- effects?: Record<string, unknown[]> | undefined;
1169
+ effects?: Record<string, SExpr[]> | undefined;
2620
1170
  refId?: TraitId | undefined;
2621
1171
  appliesTo?: string[] | undefined;
2622
1172
  linkedEntity?: string | undefined;
@@ -2632,7 +1182,7 @@ declare const TraitReferenceSchema: z.ZodEffects<z.ZodObject<{
2632
1182
  fields?: Record<string, string> | undefined;
2633
1183
  config?: Record<string, TraitConfigValue | ConfigFieldDeclaration> | undefined;
2634
1184
  events?: Record<string, string> | undefined;
2635
- effects?: Record<string, unknown[]> | undefined;
1185
+ effects?: Record<string, SExpr[]> | undefined;
2636
1186
  refId?: string | undefined;
2637
1187
  appliesTo?: string[] | undefined;
2638
1188
  linkedEntity?: string | undefined;
@@ -2658,7 +1208,7 @@ type TraitRef = string | {
2658
1208
  events?: Record<string, string>;
2659
1209
  } | Trait;
2660
1210
  type PresentationType = 'modal' | 'drawer' | 'popover' | 'inline' | 'confirm-dialog';
2661
- interface TraitUIBinding {
1211
+ type TraitUIBinding = {
2662
1212
  [stateName: string]: {
2663
1213
  presentation: PresentationType;
2664
1214
  content: AnyPatternConfig | AnyPatternConfig[];
@@ -2673,7 +1223,7 @@ interface TraitUIBinding {
2673
1223
  totalSteps?: number;
2674
1224
  };
2675
1225
  };
2676
- }
1226
+ };
2677
1227
  /**
2678
1228
  * A Trait is a reusable behavioral module with state machine.
2679
1229
  *
@@ -2703,10 +1253,10 @@ type TraitScope = 'instance' | 'collection';
2703
1253
  * validator enforces it (`ORB_T_REBIND_MISSING_FIELDS`). Mirrors the Rust
2704
1254
  * `EntityFieldContract` serde shape exactly.
2705
1255
  */
2706
- interface EntityFieldContract {
1256
+ type EntityFieldContract = {
2707
1257
  requires: string[];
2708
1258
  provides: string[];
2709
- }
1259
+ };
2710
1260
  declare const EntityFieldContractSchema: z.ZodObject<{
2711
1261
  requires: z.ZodArray<z.ZodString, "many">;
2712
1262
  provides: z.ZodArray<z.ZodString, "many">;
@@ -2717,7 +1267,7 @@ declare const EntityFieldContractSchema: z.ZodObject<{
2717
1267
  requires: string[];
2718
1268
  provides: string[];
2719
1269
  }>;
2720
- interface Trait {
1270
+ type Trait = {
2721
1271
  /** V4 dual-carry id sibling of `name` — optional until the Phase-7 flip. */
2722
1272
  id?: TraitId;
2723
1273
  name: string;
@@ -2824,14 +1374,14 @@ interface Trait {
2824
1374
  * `linkedEntity` without re-walking the import graph at runtime.
2825
1375
  */
2826
1376
  sourceEntityDefinition?: Entity;
2827
- }
1377
+ };
2828
1378
  /**
2829
1379
  * Provenance attached to a trait that was cloned from a `uses[]` import
2830
1380
  * during the inline phase. The resolved schema carries this so Studio
2831
1381
  * can group L2 cards by source behavior and offer an L3 drill into the
2832
1382
  * import's own transitions.
2833
1383
  */
2834
- interface SourceBehaviorMetadata {
1384
+ type SourceBehaviorMetadata = {
2835
1385
  /** Behavior name (e.g. "std-stat-card") — the resolved `from:` value. */
2836
1386
  behavior: string;
2837
1387
  /** Alias used at the import site (e.g. "Stat"). Multiple imports of
@@ -2840,7 +1390,7 @@ interface SourceBehaviorMetadata {
2840
1390
  /** Original trait name inside the imported behavior, before any
2841
1391
  * call-site `name:` rename. */
2842
1392
  originalName: string;
2843
- }
1393
+ };
2844
1394
  declare const TraitSchema: z.ZodObject<{
2845
1395
  id: z.ZodOptional<z.ZodEffects<z.ZodString, TraitId, string>>;
2846
1396
  name: z.ZodString;
@@ -5306,4 +3856,4 @@ declare const OrbitalTraitRefSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
5306
3856
  } | undefined;
5307
3857
  }>]>;
5308
3858
 
5309
- export { type LogEffect as $, type AgentEffect as A, type BehaviorEffect as B, type CallSiteConfig as C, type DeclaredTraitConfig as D, type Effect as E, type EvaluateConfig as F, type EvaluateEffect as G, type Event as H, type EventInput as I, type EventPayloadField as J, EventPayloadFieldSchema as K, EventSchema as L, type EventScope as M, EventScopeSchema as N, type FetchEffect as O, type FetchOptions as P, type FetchResult as Q, type ForwardConfig as R, type State as S, type TraitEventListener as T, type ForwardEffect as U, type Guard as V, type GuardInput as W, GuardSchema as X, type ListenSource as Y, ListenSourceSchema as Z, type LlmEffect as _, type TraitReference as a, type TraitConfigValue as a$, type McpServiceDef as a0, McpServiceDefSchema as a1, type MemoryEffect as a2, type NavigateEffect as a3, type NnConfig as a4, type NnLayer as a5, type NotifyEffect as a6, type OrbitalTraitRef as a7, OrbitalTraitRefSchema as a8, type OsEffect as a9, type ServiceRef as aA, type ServiceRefObject as aB, ServiceRefObjectSchema as aC, ServiceRefSchema as aD, ServiceRefStringSchema as aE, type ServiceType as aF, ServiceTypeSchema as aG, type SessionEffect as aH, type SetEffect as aI, type SocketEvents as aJ, SocketEventsSchema as aK, type SocketServiceDef as aL, SocketServiceDefSchema as aM, type SpawnEffect as aN, type StateInput as aO, type StateMachine as aP, type StateMachineInput as aQ, StateMachineSchema as aR, StateSchema as aS, type SwapEffect as aT, type TraceEffect as aU, type TrainConfig as aV, type TrainEffect as aW, type TraitCategory as aX, TraitCategorySchema as aY, type TraitConfigObject as aZ, TraitConfigSchema as a_, type PayloadField as aa, PayloadFieldSchema as ab, type PersistData as ac, type PersistEffect as ad, type PersistEmitConfig as ae, type PresentationType as af, REFERENCE_CONFIG_TYPES as ag, type RefEffect as ah, type ReferenceConfigType as ai, type RenderBinding as aj, type RenderChildrenMap as ak, type RenderItemLambda as al, type RenderUIEffect as am, type RenderUINode as an, type RequiredField as ao, RequiredFieldSchema as ap, type ResolvedPatternProps as aq, type RestAuthConfig as ar, RestAuthConfigSchema as as, type RestServiceDef as at, RestServiceDefSchema as au, SERVICE_TYPES as av, type ServiceDefinition as aw, ServiceDefinitionSchema as ax, type ServiceParams as ay, type ServiceParamsValue as az, type CallSiteConfigEntry as b, type TraitScope as b$, TraitConfigValueSchema as b0, type TraitDataEntity as b1, TraitDataEntitySchema as b2, type TraitEntityField as b3, TraitEntityFieldSchema as b4, type TraitEventContract as b5, TraitEventContractSchema as b6, TraitEventListenerSchema as b7, type TraitInput as b8, type TraitRef as b9, getTraitConfig as bA, getTraitName as bB, hasService as bC, isCallSiteConfigDeclaration as bD, isCircuitEvent as bE, isEffect as bF, isInlineTrait as bG, isMcpService as bH, isReferenceConfigType as bI, isRestService as bJ, isSExprEffect as bK, isServiceReference as bL, isServiceReferenceObject as bM, isSocketService as bN, navigate as bO, normalizeCallSiteConfigToValues as bP, normalizeTraitRef as bQ, notify as bR, parseServiceRef as bS, persist as bT, ref as bU, renderUI as bV, resolveConfigRefEventName as bW, set as bX, spawn as bY, swap as bZ, watch as b_, TraitRefSchema as ba, type TraitReferenceInput as bb, TraitReferenceSchema as bc, TraitSchema as bd, type TraitTick as be, TraitTickSchema as bf, type TraitUIBinding as bg, type Transition as bh, type TransitionInput as bi, TransitionSchema as bj, type TypedEffect as bk, type UISlot as bl, UISlotSchema as bm, UI_SLOTS as bn, type ValidateEffect as bo, type WatchEffect as bp, type WatchOptions as bq, atomic as br, callService as bs, configRefEventKnob as bt, deref as bu, despawn as bv, doEffects as bw, emit as bx, findService as by, getServiceNames as bz, type Trait as c, type TraitConfig as d, type ApplicationEffect as e, type AtomicEffect as f, CONFIG_REF_EVENT_PATTERN as g, type CallServiceConfig as h, type CallServiceEffect as i, type CheckpointLoadEffect as j, type CheckpointSaveEffect as k, type ComposeEffect as l, type ConfigFieldDeclaration as m, ConfigFieldDeclarationSchema as n, type ConfigFieldItemsDeclaration as o, type ConfigRefEventError as p, DeclaredTraitConfigSchema as q, type DerefEffect as r, type DespawnEffect as s, type DoEffect as t, type EffectInput as u, EffectSchema as v, type EmitConfig as w, type EmitEffect as x, type EntityFieldContract as y, EntityFieldContractSchema as z };
3859
+ export { TraitEventContractSchema as $, RequiredFieldSchema as A, type StateInput as B, type CallSiteConfig as C, type DeclaredTraitConfig as D, type EntityFieldContract as E, type StateMachine as F, type Guard as G, type StateMachineInput as H, StateMachineSchema as I, StateSchema as J, type TraitCategory as K, type ListenSource as L, TraitCategorySchema as M, type TraitConfigObject as N, type OrbitalTraitRef as O, type PayloadField as P, TraitConfigSchema as Q, REFERENCE_CONFIG_TYPES as R, type State as S, type TraitEventListener as T, type TraitConfigValue as U, TraitConfigValueSchema as V, type TraitDataEntity as W, TraitDataEntitySchema as X, type TraitEntityField as Y, TraitEntityFieldSchema as Z, type TraitEventContract as _, type TraitReference as a, TraitEventListenerSchema as a0, type TraitInput as a1, type TraitRef as a2, TraitRefSchema as a3, type TraitReferenceInput as a4, TraitReferenceSchema as a5, TraitSchema as a6, type TraitTick as a7, TraitTickSchema as a8, type TraitUIBinding as a9, type Transition as aa, type TransitionInput as ab, TransitionSchema as ac, configRefEventKnob as ad, getTraitConfig as ae, getTraitName as af, isCallSiteConfigDeclaration as ag, isCircuitEvent as ah, isInlineTrait as ai, isReferenceConfigType as aj, normalizeCallSiteConfigToValues as ak, normalizeTraitRef as al, resolveConfigRefEventName as am, type TraitScope as an, type CallSiteConfigEntry as b, type Trait as c, type TraitConfig as d, CONFIG_REF_EVENT_PATTERN as e, type ConfigFieldDeclaration as f, ConfigFieldDeclarationSchema as g, type ConfigFieldItemsDeclaration as h, type ConfigRefEventError as i, DeclaredTraitConfigSchema as j, EntityFieldContractSchema as k, type Event as l, type EventInput as m, type EventPayloadField as n, EventPayloadFieldSchema as o, EventSchema as p, type EventScope as q, EventScopeSchema as r, type GuardInput as s, GuardSchema as t, ListenSourceSchema as u, OrbitalTraitRefSchema as v, PayloadFieldSchema as w, type PresentationType as x, type ReferenceConfigType as y, type RequiredField as z };