@loop-engine/core 0.1.0 → 0.1.1

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/index.d.ts CHANGED
@@ -1,2 +1,386 @@
1
- export * from "./types";
2
- //# sourceMappingURL=index.d.ts.map
1
+ import { z } from 'zod';
2
+
3
+ declare const LoopIdSchema: z.ZodBranded<z.ZodString, "LoopId">;
4
+ type LoopId = z.infer<typeof LoopIdSchema>;
5
+ declare const AggregateIdSchema: z.ZodBranded<z.ZodString, "AggregateId">;
6
+ type AggregateId = z.infer<typeof AggregateIdSchema>;
7
+ declare const ActorIdSchema: z.ZodBranded<z.ZodString, "ActorId">;
8
+ type ActorId = z.infer<typeof ActorIdSchema>;
9
+ declare const SignalIdSchema: z.ZodBranded<z.ZodString, "SignalId">;
10
+ type SignalId = z.infer<typeof SignalIdSchema>;
11
+ declare const GuardIdSchema: z.ZodBranded<z.ZodString, "GuardId">;
12
+ type GuardId = z.infer<typeof GuardIdSchema>;
13
+ declare const StateIdSchema: z.ZodBranded<z.ZodString, "StateId">;
14
+ type StateId = z.infer<typeof StateIdSchema>;
15
+ declare const TransitionIdSchema: z.ZodBranded<z.ZodString, "TransitionId">;
16
+ type TransitionId = z.infer<typeof TransitionIdSchema>;
17
+ declare const LoopStatusSchema: z.ZodEnum<["pending", "active", "completed", "failed", "cancelled", "suspended"]>;
18
+ type LoopStatus = z.infer<typeof LoopStatusSchema>;
19
+ declare const ActorTypeSchema: z.ZodEnum<["human", "automation", "ai-agent"]>;
20
+ type ActorType = z.infer<typeof ActorTypeSchema>;
21
+ declare const ActorRefSchema: z.ZodObject<{
22
+ id: z.ZodBranded<z.ZodString, "ActorId">;
23
+ type: z.ZodEnum<["human", "automation", "ai-agent"]>;
24
+ displayName: z.ZodOptional<z.ZodString>;
25
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ type: "human" | "automation" | "ai-agent";
28
+ id: string & z.BRAND<"ActorId">;
29
+ displayName?: string | undefined;
30
+ metadata?: Record<string, unknown> | undefined;
31
+ }, {
32
+ type: "human" | "automation" | "ai-agent";
33
+ id: string;
34
+ displayName?: string | undefined;
35
+ metadata?: Record<string, unknown> | undefined;
36
+ }>;
37
+ type ActorRef = z.infer<typeof ActorRefSchema>;
38
+ declare const GuardSeveritySchema: z.ZodEnum<["hard", "soft"]>;
39
+ type GuardSeverity = z.infer<typeof GuardSeveritySchema>;
40
+ declare const GuardSpecSchema: z.ZodObject<{
41
+ guardId: z.ZodBranded<z.ZodString, "GuardId">;
42
+ description: z.ZodString;
43
+ severity: z.ZodEnum<["hard", "soft"]>;
44
+ evaluatedBy: z.ZodEnum<["runtime", "module", "external"]>;
45
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ guardId: string & z.BRAND<"GuardId">;
48
+ description: string;
49
+ severity: "hard" | "soft";
50
+ evaluatedBy: "runtime" | "module" | "external";
51
+ parameters?: Record<string, unknown> | undefined;
52
+ }, {
53
+ guardId: string;
54
+ description: string;
55
+ severity: "hard" | "soft";
56
+ evaluatedBy: "runtime" | "module" | "external";
57
+ parameters?: Record<string, unknown> | undefined;
58
+ }>;
59
+ type GuardSpec = z.infer<typeof GuardSpecSchema>;
60
+ declare const TransitionSpecSchema: z.ZodObject<{
61
+ transitionId: z.ZodBranded<z.ZodString, "TransitionId">;
62
+ from: z.ZodBranded<z.ZodString, "StateId">;
63
+ to: z.ZodBranded<z.ZodString, "StateId">;
64
+ signal: z.ZodBranded<z.ZodString, "SignalId">;
65
+ allowedActors: z.ZodArray<z.ZodEnum<["human", "automation", "ai-agent"]>, "many">;
66
+ guards: z.ZodOptional<z.ZodArray<z.ZodObject<{
67
+ guardId: z.ZodBranded<z.ZodString, "GuardId">;
68
+ description: z.ZodString;
69
+ severity: z.ZodEnum<["hard", "soft"]>;
70
+ evaluatedBy: z.ZodEnum<["runtime", "module", "external"]>;
71
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ guardId: string & z.BRAND<"GuardId">;
74
+ description: string;
75
+ severity: "hard" | "soft";
76
+ evaluatedBy: "runtime" | "module" | "external";
77
+ parameters?: Record<string, unknown> | undefined;
78
+ }, {
79
+ guardId: string;
80
+ description: string;
81
+ severity: "hard" | "soft";
82
+ evaluatedBy: "runtime" | "module" | "external";
83
+ parameters?: Record<string, unknown> | undefined;
84
+ }>, "many">>;
85
+ description: z.ZodOptional<z.ZodString>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ transitionId: string & z.BRAND<"TransitionId">;
88
+ from: string & z.BRAND<"StateId">;
89
+ to: string & z.BRAND<"StateId">;
90
+ signal: string & z.BRAND<"SignalId">;
91
+ allowedActors: ("human" | "automation" | "ai-agent")[];
92
+ description?: string | undefined;
93
+ guards?: {
94
+ guardId: string & z.BRAND<"GuardId">;
95
+ description: string;
96
+ severity: "hard" | "soft";
97
+ evaluatedBy: "runtime" | "module" | "external";
98
+ parameters?: Record<string, unknown> | undefined;
99
+ }[] | undefined;
100
+ }, {
101
+ transitionId: string;
102
+ from: string;
103
+ to: string;
104
+ signal: string;
105
+ allowedActors: ("human" | "automation" | "ai-agent")[];
106
+ description?: string | undefined;
107
+ guards?: {
108
+ guardId: string;
109
+ description: string;
110
+ severity: "hard" | "soft";
111
+ evaluatedBy: "runtime" | "module" | "external";
112
+ parameters?: Record<string, unknown> | undefined;
113
+ }[] | undefined;
114
+ }>;
115
+ type TransitionSpec = z.infer<typeof TransitionSpecSchema>;
116
+ declare const StateSpecSchema: z.ZodObject<{
117
+ stateId: z.ZodBranded<z.ZodString, "StateId">;
118
+ label: z.ZodString;
119
+ terminal: z.ZodOptional<z.ZodBoolean>;
120
+ description: z.ZodOptional<z.ZodString>;
121
+ }, "strip", z.ZodTypeAny, {
122
+ stateId: string & z.BRAND<"StateId">;
123
+ label: string;
124
+ description?: string | undefined;
125
+ terminal?: boolean | undefined;
126
+ }, {
127
+ stateId: string;
128
+ label: string;
129
+ description?: string | undefined;
130
+ terminal?: boolean | undefined;
131
+ }>;
132
+ type StateSpec = z.infer<typeof StateSpecSchema>;
133
+ declare const BusinessMetricSchema: z.ZodObject<{
134
+ id: z.ZodString;
135
+ label: z.ZodString;
136
+ unit: z.ZodString;
137
+ improvableByAI: z.ZodOptional<z.ZodBoolean>;
138
+ }, "strip", z.ZodTypeAny, {
139
+ id: string;
140
+ label: string;
141
+ unit: string;
142
+ improvableByAI?: boolean | undefined;
143
+ }, {
144
+ id: string;
145
+ label: string;
146
+ unit: string;
147
+ improvableByAI?: boolean | undefined;
148
+ }>;
149
+ type BusinessMetric = z.infer<typeof BusinessMetricSchema>;
150
+ declare const OutcomeSpecSchema: z.ZodObject<{
151
+ description: z.ZodString;
152
+ valueUnit: z.ZodString;
153
+ businessMetrics: z.ZodArray<z.ZodObject<{
154
+ id: z.ZodString;
155
+ label: z.ZodString;
156
+ unit: z.ZodString;
157
+ improvableByAI: z.ZodOptional<z.ZodBoolean>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ id: string;
160
+ label: string;
161
+ unit: string;
162
+ improvableByAI?: boolean | undefined;
163
+ }, {
164
+ id: string;
165
+ label: string;
166
+ unit: string;
167
+ improvableByAI?: boolean | undefined;
168
+ }>, "many">;
169
+ }, "strip", z.ZodTypeAny, {
170
+ description: string;
171
+ valueUnit: string;
172
+ businessMetrics: {
173
+ id: string;
174
+ label: string;
175
+ unit: string;
176
+ improvableByAI?: boolean | undefined;
177
+ }[];
178
+ }, {
179
+ description: string;
180
+ valueUnit: string;
181
+ businessMetrics: {
182
+ id: string;
183
+ label: string;
184
+ unit: string;
185
+ improvableByAI?: boolean | undefined;
186
+ }[];
187
+ }>;
188
+ type OutcomeSpec = z.infer<typeof OutcomeSpecSchema>;
189
+ declare const LoopDefinitionSchema: z.ZodObject<{
190
+ loopId: z.ZodBranded<z.ZodString, "LoopId">;
191
+ version: z.ZodString;
192
+ name: z.ZodString;
193
+ description: z.ZodString;
194
+ states: z.ZodArray<z.ZodObject<{
195
+ stateId: z.ZodBranded<z.ZodString, "StateId">;
196
+ label: z.ZodString;
197
+ terminal: z.ZodOptional<z.ZodBoolean>;
198
+ description: z.ZodOptional<z.ZodString>;
199
+ }, "strip", z.ZodTypeAny, {
200
+ stateId: string & z.BRAND<"StateId">;
201
+ label: string;
202
+ description?: string | undefined;
203
+ terminal?: boolean | undefined;
204
+ }, {
205
+ stateId: string;
206
+ label: string;
207
+ description?: string | undefined;
208
+ terminal?: boolean | undefined;
209
+ }>, "many">;
210
+ initialState: z.ZodBranded<z.ZodString, "StateId">;
211
+ transitions: z.ZodArray<z.ZodObject<{
212
+ transitionId: z.ZodBranded<z.ZodString, "TransitionId">;
213
+ from: z.ZodBranded<z.ZodString, "StateId">;
214
+ to: z.ZodBranded<z.ZodString, "StateId">;
215
+ signal: z.ZodBranded<z.ZodString, "SignalId">;
216
+ allowedActors: z.ZodArray<z.ZodEnum<["human", "automation", "ai-agent"]>, "many">;
217
+ guards: z.ZodOptional<z.ZodArray<z.ZodObject<{
218
+ guardId: z.ZodBranded<z.ZodString, "GuardId">;
219
+ description: z.ZodString;
220
+ severity: z.ZodEnum<["hard", "soft"]>;
221
+ evaluatedBy: z.ZodEnum<["runtime", "module", "external"]>;
222
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
223
+ }, "strip", z.ZodTypeAny, {
224
+ guardId: string & z.BRAND<"GuardId">;
225
+ description: string;
226
+ severity: "hard" | "soft";
227
+ evaluatedBy: "runtime" | "module" | "external";
228
+ parameters?: Record<string, unknown> | undefined;
229
+ }, {
230
+ guardId: string;
231
+ description: string;
232
+ severity: "hard" | "soft";
233
+ evaluatedBy: "runtime" | "module" | "external";
234
+ parameters?: Record<string, unknown> | undefined;
235
+ }>, "many">>;
236
+ description: z.ZodOptional<z.ZodString>;
237
+ }, "strip", z.ZodTypeAny, {
238
+ transitionId: string & z.BRAND<"TransitionId">;
239
+ from: string & z.BRAND<"StateId">;
240
+ to: string & z.BRAND<"StateId">;
241
+ signal: string & z.BRAND<"SignalId">;
242
+ allowedActors: ("human" | "automation" | "ai-agent")[];
243
+ description?: string | undefined;
244
+ guards?: {
245
+ guardId: string & z.BRAND<"GuardId">;
246
+ description: string;
247
+ severity: "hard" | "soft";
248
+ evaluatedBy: "runtime" | "module" | "external";
249
+ parameters?: Record<string, unknown> | undefined;
250
+ }[] | undefined;
251
+ }, {
252
+ transitionId: string;
253
+ from: string;
254
+ to: string;
255
+ signal: string;
256
+ allowedActors: ("human" | "automation" | "ai-agent")[];
257
+ description?: string | undefined;
258
+ guards?: {
259
+ guardId: string;
260
+ description: string;
261
+ severity: "hard" | "soft";
262
+ evaluatedBy: "runtime" | "module" | "external";
263
+ parameters?: Record<string, unknown> | undefined;
264
+ }[] | undefined;
265
+ }>, "many">;
266
+ outcome: z.ZodOptional<z.ZodObject<{
267
+ description: z.ZodString;
268
+ valueUnit: z.ZodString;
269
+ businessMetrics: z.ZodArray<z.ZodObject<{
270
+ id: z.ZodString;
271
+ label: z.ZodString;
272
+ unit: z.ZodString;
273
+ improvableByAI: z.ZodOptional<z.ZodBoolean>;
274
+ }, "strip", z.ZodTypeAny, {
275
+ id: string;
276
+ label: string;
277
+ unit: string;
278
+ improvableByAI?: boolean | undefined;
279
+ }, {
280
+ id: string;
281
+ label: string;
282
+ unit: string;
283
+ improvableByAI?: boolean | undefined;
284
+ }>, "many">;
285
+ }, "strip", z.ZodTypeAny, {
286
+ description: string;
287
+ valueUnit: string;
288
+ businessMetrics: {
289
+ id: string;
290
+ label: string;
291
+ unit: string;
292
+ improvableByAI?: boolean | undefined;
293
+ }[];
294
+ }, {
295
+ description: string;
296
+ valueUnit: string;
297
+ businessMetrics: {
298
+ id: string;
299
+ label: string;
300
+ unit: string;
301
+ improvableByAI?: boolean | undefined;
302
+ }[];
303
+ }>>;
304
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
305
+ }, "strip", z.ZodTypeAny, {
306
+ description: string;
307
+ loopId: string & z.BRAND<"LoopId">;
308
+ version: string;
309
+ name: string;
310
+ states: {
311
+ stateId: string & z.BRAND<"StateId">;
312
+ label: string;
313
+ description?: string | undefined;
314
+ terminal?: boolean | undefined;
315
+ }[];
316
+ initialState: string & z.BRAND<"StateId">;
317
+ transitions: {
318
+ transitionId: string & z.BRAND<"TransitionId">;
319
+ from: string & z.BRAND<"StateId">;
320
+ to: string & z.BRAND<"StateId">;
321
+ signal: string & z.BRAND<"SignalId">;
322
+ allowedActors: ("human" | "automation" | "ai-agent")[];
323
+ description?: string | undefined;
324
+ guards?: {
325
+ guardId: string & z.BRAND<"GuardId">;
326
+ description: string;
327
+ severity: "hard" | "soft";
328
+ evaluatedBy: "runtime" | "module" | "external";
329
+ parameters?: Record<string, unknown> | undefined;
330
+ }[] | undefined;
331
+ }[];
332
+ outcome?: {
333
+ description: string;
334
+ valueUnit: string;
335
+ businessMetrics: {
336
+ id: string;
337
+ label: string;
338
+ unit: string;
339
+ improvableByAI?: boolean | undefined;
340
+ }[];
341
+ } | undefined;
342
+ tags?: string[] | undefined;
343
+ }, {
344
+ description: string;
345
+ loopId: string;
346
+ version: string;
347
+ name: string;
348
+ states: {
349
+ stateId: string;
350
+ label: string;
351
+ description?: string | undefined;
352
+ terminal?: boolean | undefined;
353
+ }[];
354
+ initialState: string;
355
+ transitions: {
356
+ transitionId: string;
357
+ from: string;
358
+ to: string;
359
+ signal: string;
360
+ allowedActors: ("human" | "automation" | "ai-agent")[];
361
+ description?: string | undefined;
362
+ guards?: {
363
+ guardId: string;
364
+ description: string;
365
+ severity: "hard" | "soft";
366
+ evaluatedBy: "runtime" | "module" | "external";
367
+ parameters?: Record<string, unknown> | undefined;
368
+ }[] | undefined;
369
+ }[];
370
+ outcome?: {
371
+ description: string;
372
+ valueUnit: string;
373
+ businessMetrics: {
374
+ id: string;
375
+ label: string;
376
+ unit: string;
377
+ improvableByAI?: boolean | undefined;
378
+ }[];
379
+ } | undefined;
380
+ tags?: string[] | undefined;
381
+ }>;
382
+ type LoopDefinition = z.infer<typeof LoopDefinitionSchema>;
383
+
384
+ declare const LOOP_ENGINE_CORE_VERSION = "0.1.0";
385
+
386
+ export { type ActorId, ActorIdSchema, type ActorRef, ActorRefSchema, type ActorType, ActorTypeSchema, type AggregateId, AggregateIdSchema, type BusinessMetric, BusinessMetricSchema, type GuardId, GuardIdSchema, type GuardSeverity, GuardSeveritySchema, type GuardSpec, GuardSpecSchema, LOOP_ENGINE_CORE_VERSION, type LoopDefinition, LoopDefinitionSchema, type LoopId, LoopIdSchema, type LoopStatus, LoopStatusSchema, type OutcomeSpec, OutcomeSpecSchema, type SignalId, SignalIdSchema, type StateId, StateIdSchema, type StateSpec, StateSpecSchema, type TransitionId, TransitionIdSchema, type TransitionSpec, TransitionSpecSchema };
package/dist/index.js CHANGED
@@ -1,4 +1,94 @@
1
- // @license MIT
2
- // SPDX-License-Identifier: MIT
3
- export * from "./types";
1
+ // src/schemas.ts
2
+ import { z } from "zod";
3
+ var LoopIdSchema = z.string().brand();
4
+ var AggregateIdSchema = z.string().brand();
5
+ var ActorIdSchema = z.string().brand();
6
+ var SignalIdSchema = z.string().brand();
7
+ var GuardIdSchema = z.string().brand();
8
+ var StateIdSchema = z.string().brand();
9
+ var TransitionIdSchema = z.string().brand();
10
+ var LoopStatusSchema = z.enum([
11
+ "pending",
12
+ "active",
13
+ "completed",
14
+ "failed",
15
+ "cancelled",
16
+ "suspended"
17
+ ]);
18
+ var ActorTypeSchema = z.enum(["human", "automation", "ai-agent"]);
19
+ var ActorRefSchema = z.object({
20
+ id: ActorIdSchema,
21
+ type: ActorTypeSchema,
22
+ displayName: z.string().optional(),
23
+ metadata: z.record(z.unknown()).optional()
24
+ });
25
+ var GuardSeveritySchema = z.enum(["hard", "soft"]);
26
+ var GuardSpecSchema = z.object({
27
+ guardId: GuardIdSchema,
28
+ description: z.string(),
29
+ severity: GuardSeveritySchema,
30
+ evaluatedBy: z.enum(["runtime", "module", "external"]),
31
+ parameters: z.record(z.unknown()).optional()
32
+ });
33
+ var TransitionSpecSchema = z.object({
34
+ transitionId: TransitionIdSchema,
35
+ from: StateIdSchema,
36
+ to: StateIdSchema,
37
+ signal: SignalIdSchema,
38
+ allowedActors: z.array(ActorTypeSchema).min(1),
39
+ guards: z.array(GuardSpecSchema).optional(),
40
+ description: z.string().optional()
41
+ });
42
+ var StateSpecSchema = z.object({
43
+ stateId: StateIdSchema,
44
+ label: z.string(),
45
+ terminal: z.boolean().optional(),
46
+ description: z.string().optional()
47
+ });
48
+ var BusinessMetricSchema = z.object({
49
+ id: z.string(),
50
+ label: z.string(),
51
+ unit: z.string(),
52
+ improvableByAI: z.boolean().optional()
53
+ });
54
+ var OutcomeSpecSchema = z.object({
55
+ description: z.string(),
56
+ valueUnit: z.string(),
57
+ businessMetrics: z.array(BusinessMetricSchema)
58
+ });
59
+ var LoopDefinitionSchema = z.object({
60
+ loopId: LoopIdSchema,
61
+ version: z.string(),
62
+ name: z.string(),
63
+ description: z.string(),
64
+ states: z.array(StateSpecSchema),
65
+ initialState: StateIdSchema,
66
+ transitions: z.array(TransitionSpecSchema),
67
+ outcome: OutcomeSpecSchema.optional(),
68
+ tags: z.array(z.string()).optional()
69
+ });
70
+
71
+ // src/index.ts
72
+ var LOOP_ENGINE_CORE_VERSION = "0.1.0";
73
+ export {
74
+ ActorIdSchema,
75
+ ActorRefSchema,
76
+ ActorTypeSchema,
77
+ AggregateIdSchema,
78
+ BusinessMetricSchema,
79
+ GuardIdSchema,
80
+ GuardSeveritySchema,
81
+ GuardSpecSchema,
82
+ LOOP_ENGINE_CORE_VERSION,
83
+ LoopDefinitionSchema,
84
+ LoopIdSchema,
85
+ LoopStatusSchema,
86
+ OutcomeSpecSchema,
87
+ SignalIdSchema,
88
+ StateIdSchema,
89
+ StateSpecSchema,
90
+ TransitionIdSchema,
91
+ TransitionSpecSchema
92
+ };
93
+ // @license Apache-2.0
4
94
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,+BAA+B;AAE/B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../src/schemas.ts","../src/index.ts"],"sourcesContent":["// @license Apache-2.0\n// SPDX-License-Identifier: Apache-2.0\n\nimport { z } from \"zod\";\n\nexport const LoopIdSchema = z.string().brand<\"LoopId\">();\nexport type LoopId = z.infer<typeof LoopIdSchema>;\n\nexport const AggregateIdSchema = z.string().brand<\"AggregateId\">();\nexport type AggregateId = z.infer<typeof AggregateIdSchema>;\n\nexport const ActorIdSchema = z.string().brand<\"ActorId\">();\nexport type ActorId = z.infer<typeof ActorIdSchema>;\n\nexport const SignalIdSchema = z.string().brand<\"SignalId\">();\nexport type SignalId = z.infer<typeof SignalIdSchema>;\n\nexport const GuardIdSchema = z.string().brand<\"GuardId\">();\nexport type GuardId = z.infer<typeof GuardIdSchema>;\n\nexport const StateIdSchema = z.string().brand<\"StateId\">();\nexport type StateId = z.infer<typeof StateIdSchema>;\n\nexport const TransitionIdSchema = z.string().brand<\"TransitionId\">();\nexport type TransitionId = z.infer<typeof TransitionIdSchema>;\n\nexport const LoopStatusSchema = z.enum([\n \"pending\",\n \"active\",\n \"completed\",\n \"failed\",\n \"cancelled\",\n \"suspended\"\n]);\nexport type LoopStatus = z.infer<typeof LoopStatusSchema>;\n\nexport const ActorTypeSchema = z.enum([\"human\", \"automation\", \"ai-agent\"]);\nexport type ActorType = z.infer<typeof ActorTypeSchema>;\n\nexport const ActorRefSchema = z.object({\n id: ActorIdSchema,\n type: ActorTypeSchema,\n displayName: z.string().optional(),\n metadata: z.record(z.unknown()).optional()\n});\nexport type ActorRef = z.infer<typeof ActorRefSchema>;\n\nexport const GuardSeveritySchema = z.enum([\"hard\", \"soft\"]);\nexport type GuardSeverity = z.infer<typeof GuardSeveritySchema>;\n\nexport const GuardSpecSchema = z.object({\n guardId: GuardIdSchema,\n description: z.string(),\n severity: GuardSeveritySchema,\n evaluatedBy: z.enum([\"runtime\", \"module\", \"external\"]),\n parameters: z.record(z.unknown()).optional()\n});\nexport type GuardSpec = z.infer<typeof GuardSpecSchema>;\n\nexport const TransitionSpecSchema = z.object({\n transitionId: TransitionIdSchema,\n from: StateIdSchema,\n to: StateIdSchema,\n signal: SignalIdSchema,\n allowedActors: z.array(ActorTypeSchema).min(1),\n guards: z.array(GuardSpecSchema).optional(),\n description: z.string().optional()\n});\nexport type TransitionSpec = z.infer<typeof TransitionSpecSchema>;\n\nexport const StateSpecSchema = z.object({\n stateId: StateIdSchema,\n label: z.string(),\n terminal: z.boolean().optional(),\n description: z.string().optional()\n});\nexport type StateSpec = z.infer<typeof StateSpecSchema>;\n\nexport const BusinessMetricSchema = z.object({\n id: z.string(),\n label: z.string(),\n unit: z.string(),\n improvableByAI: z.boolean().optional()\n});\nexport type BusinessMetric = z.infer<typeof BusinessMetricSchema>;\n\nexport const OutcomeSpecSchema = z.object({\n description: z.string(),\n valueUnit: z.string(),\n businessMetrics: z.array(BusinessMetricSchema)\n});\nexport type OutcomeSpec = z.infer<typeof OutcomeSpecSchema>;\n\nexport const LoopDefinitionSchema = z.object({\n loopId: LoopIdSchema,\n version: z.string(),\n name: z.string(),\n description: z.string(),\n states: z.array(StateSpecSchema),\n initialState: StateIdSchema,\n transitions: z.array(TransitionSpecSchema),\n outcome: OutcomeSpecSchema.optional(),\n tags: z.array(z.string()).optional()\n});\nexport type LoopDefinition = z.infer<typeof LoopDefinitionSchema>;\n","// @license Apache-2.0\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./schemas\";\n\nexport const LOOP_ENGINE_CORE_VERSION = \"0.1.0\";\n"],"mappings":";AAGA,SAAS,SAAS;AAEX,IAAM,eAAe,EAAE,OAAO,EAAE,MAAgB;AAGhD,IAAM,oBAAoB,EAAE,OAAO,EAAE,MAAqB;AAG1D,IAAM,gBAAgB,EAAE,OAAO,EAAE,MAAiB;AAGlD,IAAM,iBAAiB,EAAE,OAAO,EAAE,MAAkB;AAGpD,IAAM,gBAAgB,EAAE,OAAO,EAAE,MAAiB;AAGlD,IAAM,gBAAgB,EAAE,OAAO,EAAE,MAAiB;AAGlD,IAAM,qBAAqB,EAAE,OAAO,EAAE,MAAsB;AAG5D,IAAM,mBAAmB,EAAE,KAAK;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,kBAAkB,EAAE,KAAK,CAAC,SAAS,cAAc,UAAU,CAAC;AAGlE,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC3C,CAAC;AAGM,IAAM,sBAAsB,EAAE,KAAK,CAAC,QAAQ,MAAM,CAAC;AAGnD,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,SAAS;AAAA,EACT,aAAa,EAAE,OAAO;AAAA,EACtB,UAAU;AAAA,EACV,aAAa,EAAE,KAAK,CAAC,WAAW,UAAU,UAAU,CAAC;AAAA,EACrD,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC7C,CAAC;AAGM,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,cAAc;AAAA,EACd,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,eAAe,EAAE,MAAM,eAAe,EAAE,IAAI,CAAC;AAAA,EAC7C,QAAQ,EAAE,MAAM,eAAe,EAAE,SAAS;AAAA,EAC1C,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAGM,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,SAAS;AAAA,EACT,OAAO,EAAE,OAAO;AAAA,EAChB,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC/B,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAGM,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,IAAI,EAAE,OAAO;AAAA,EACb,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,gBAAgB,EAAE,QAAQ,EAAE,SAAS;AACvC,CAAC;AAGM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,aAAa,EAAE,OAAO;AAAA,EACtB,WAAW,EAAE,OAAO;AAAA,EACpB,iBAAiB,EAAE,MAAM,oBAAoB;AAC/C,CAAC;AAGM,IAAM,uBAAuB,EAAE,OAAO;AAAA,EAC3C,QAAQ;AAAA,EACR,SAAS,EAAE,OAAO;AAAA,EAClB,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO;AAAA,EACtB,QAAQ,EAAE,MAAM,eAAe;AAAA,EAC/B,cAAc;AAAA,EACd,aAAa,EAAE,MAAM,oBAAoB;AAAA,EACzC,SAAS,kBAAkB,SAAS;AAAA,EACpC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AACrC,CAAC;;;AClGM,IAAM,2BAA2B;","names":[]}
package/package.json CHANGED
@@ -1,28 +1,34 @@
1
1
  {
2
2
  "name": "@loop-engine/core",
3
- "version": "0.1.0",
4
- "license": "MIT",
5
- "description": "Domain model types for the Loop Engine - zero dependencies",
3
+ "version": "0.1.1",
4
+ "license": "Apache-2.0",
5
+ "description": "Core domain model and schemas for Loop Engine",
6
6
  "type": "module",
7
- "main": "./dist/index.js",
7
+ "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "import": "./dist/index.js",
13
- "require": "./dist/index.js",
13
+ "require": "./dist/index.cjs",
14
14
  "types": "./dist/index.d.ts"
15
15
  }
16
16
  },
17
- "dependencies": {},
17
+ "scripts": {
18
+ "build": "tsup",
19
+ "typecheck": "tsc -p tsconfig.json --noEmit",
20
+ "test": "vitest run"
21
+ },
22
+ "dependencies": {
23
+ "zod": "^3.22.0"
24
+ },
25
+ "devDependencies": {},
18
26
  "files": [
19
27
  "dist/",
20
28
  "README.md",
21
29
  "LICENSE"
22
30
  ],
23
- "scripts": {
24
- "build": "tsc -p tsconfig.json",
25
- "typecheck": "tsc -p tsconfig.json --noEmit",
26
- "test": "vitest run"
31
+ "engines": {
32
+ "node": ">=18.0.0"
27
33
  }
28
- }
34
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,138 +0,0 @@
1
- export type LoopId = string & {
2
- readonly __brand: "LoopId";
3
- };
4
- export type StateId = string & {
5
- readonly __brand: "StateId";
6
- };
7
- export type TransitionId = string & {
8
- readonly __brand: "TransitionId";
9
- };
10
- export type AggregateId = string & {
11
- readonly __brand: "AggregateId";
12
- };
13
- export type ActorId = string & {
14
- readonly __brand: "ActorId";
15
- };
16
- export type GuardId = string & {
17
- readonly __brand: "GuardId";
18
- };
19
- export type SignalId = string & {
20
- readonly __brand: "SignalId";
21
- };
22
- export type OutcomeId = string & {
23
- readonly __brand: "OutcomeId";
24
- };
25
- export type CorrelationId = string & {
26
- readonly __brand: "CorrelationId";
27
- };
28
- export declare function loopId(s: string): LoopId;
29
- export declare function stateId(s: string): StateId;
30
- export declare function transitionId(s: string): TransitionId;
31
- export declare function aggregateId(s: string): AggregateId;
32
- export declare function actorId(s: string): ActorId;
33
- export declare function guardId(s: string): GuardId;
34
- export declare function signalId(s: string): SignalId;
35
- export declare function outcomeId(s: string): OutcomeId;
36
- export declare function correlationId(s: string): CorrelationId;
37
- export type ActorType = "human" | "automation" | "ai-agent" | "webhook" | "system";
38
- export type LoopStatus = "OPEN" | "IN_PROGRESS" | "CLOSED" | "ERROR" | "CANCELLED";
39
- export interface GuardSpec {
40
- id: GuardId;
41
- description: string;
42
- failureMessage: string;
43
- severity: "hard" | "soft";
44
- evaluatedBy: "runtime" | "module" | "external";
45
- }
46
- export interface BusinessMetric {
47
- id: string;
48
- label: string;
49
- unit: "boolean" | "days" | "units" | "currency" | "percentage" | string;
50
- improvableByAI: boolean;
51
- }
52
- export interface OutcomeSpec {
53
- id: OutcomeId;
54
- description: string;
55
- valueUnit: string;
56
- measurable: boolean;
57
- businessMetrics?: BusinessMetric[];
58
- }
59
- export interface SideEffectSpec {
60
- id: string;
61
- description: string;
62
- triggeredBy: TransitionId;
63
- }
64
- export interface TransitionSpec {
65
- id: TransitionId;
66
- from: StateId;
67
- to: StateId;
68
- allowedActors: ActorType[];
69
- guards?: GuardSpec[];
70
- sideEffects?: SideEffectSpec[];
71
- description?: string;
72
- }
73
- export interface StateSpec {
74
- id: StateId;
75
- description?: string;
76
- isTerminal?: boolean;
77
- isError?: boolean;
78
- }
79
- export interface LoopDefinition {
80
- id: LoopId;
81
- version: string;
82
- description: string;
83
- domain: string;
84
- states: StateSpec[];
85
- initialState: StateId;
86
- transitions: TransitionSpec[];
87
- outcome: OutcomeSpec;
88
- participants?: string[];
89
- spawnableLoops?: LoopId[];
90
- metadata?: Record<string, unknown>;
91
- }
92
- export interface LoopRegistry {
93
- get(loopId: LoopId): LoopDefinition | undefined;
94
- list(domain?: string): LoopDefinition[];
95
- }
96
- export interface ActorRef {
97
- type: ActorType;
98
- id: ActorId;
99
- displayName?: string;
100
- sessionId?: string;
101
- agentId?: string;
102
- }
103
- export interface Evidence {
104
- [key: string]: unknown;
105
- }
106
- export interface LoopInstance {
107
- loopId: LoopId;
108
- aggregateId: AggregateId;
109
- orgId: string;
110
- currentState: StateId;
111
- status: LoopStatus;
112
- startedAt: string;
113
- closedAt?: string;
114
- correlationId: CorrelationId;
115
- metadata?: Record<string, unknown>;
116
- }
117
- export interface TransitionRecord {
118
- id: string;
119
- loopId: LoopId;
120
- aggregateId: AggregateId;
121
- transitionId: TransitionId;
122
- fromState: StateId;
123
- toState: StateId;
124
- actor: ActorRef;
125
- evidence: Evidence;
126
- occurredAt: string;
127
- durationMs?: number;
128
- }
129
- export interface Signal {
130
- id: SignalId;
131
- type: string;
132
- subject: string;
133
- confidence?: number;
134
- observedAt: string;
135
- payload: Record<string, unknown>;
136
- triggeredLoopId?: LoopId;
137
- }
138
- //# sourceMappingURL=types.d.ts.map