@almadar/core 10.31.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.
- package/dist/{builders-DDcCVboe.d.ts → builders-CnPRr1cq.d.ts} +3 -3
- package/dist/builders.d.ts +4 -4
- package/dist/{pattern-types-VDIr2TkX.d.ts → effect-8eas3tpU.d.ts} +1457 -4
- package/dist/{expression-CB9R3KWk.d.ts → expression-BlFrxmNB.d.ts} +1 -1
- package/dist/factory/index.d.ts +6 -6
- package/dist/factory-runtime/index.d.ts +4 -4
- package/dist/index.d.ts +30 -10
- package/dist/index.js +228 -112
- package/dist/index.js.map +1 -1
- package/dist/patterns/component-mapping.json +1 -1
- package/dist/patterns/event-contracts.json +14 -1
- package/dist/patterns/index.d.ts +174 -142
- package/dist/patterns/index.js +115 -85
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/patterns-registry.json +83 -82
- package/dist/patterns/registry.json +83 -82
- package/dist/state-machine/index.d.ts +13 -2
- package/dist/state-machine/index.js +48 -23
- package/dist/state-machine/index.js.map +1 -1
- package/dist/{trait-DE6VU4Cd.d.ts → trait-CMGaEccZ.d.ts} +3 -1454
- package/dist/types/index.d.ts +11 -9
- package/dist/types/index.js.map +1 -1
- package/dist/{types-DSfz2mr5.d.ts → types-B6IYPXZM.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -1,1458 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
-
type 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
|
*/
|
|
@@ -5307,4 +3856,4 @@ declare const OrbitalTraitRefSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
|
5307
3856
|
} | undefined;
|
|
5308
3857
|
}>]>;
|
|
5309
3858
|
|
|
5310
|
-
export {
|
|
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 };
|