@loop-engine/core 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Loop Engine Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // @license MIT
2
+ // SPDX-License-Identifier: MIT
3
+ export * from "./types";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,+BAA+B;AAE/B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,138 @@
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
@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AED,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
package/dist/types.js ADDED
@@ -0,0 +1,31 @@
1
+ // @license MIT
2
+ // SPDX-License-Identifier: MIT
3
+ // Helper to cast strings to branded types safely
4
+ export function loopId(s) {
5
+ return s;
6
+ }
7
+ export function stateId(s) {
8
+ return s;
9
+ }
10
+ export function transitionId(s) {
11
+ return s;
12
+ }
13
+ export function aggregateId(s) {
14
+ return s;
15
+ }
16
+ export function actorId(s) {
17
+ return s;
18
+ }
19
+ export function guardId(s) {
20
+ return s;
21
+ }
22
+ export function signalId(s) {
23
+ return s;
24
+ }
25
+ export function outcomeId(s) {
26
+ return s;
27
+ }
28
+ export function correlationId(s) {
29
+ return s;
30
+ }
31
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,+BAA+B;AAa/B,iDAAiD;AACjD,MAAM,UAAU,MAAM,CAAC,CAAS;IAC9B,OAAO,CAAW,CAAC;AACrB,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,CAAY,CAAC;AACtB,CAAC;AACD,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,CAAiB,CAAC;AAC3B,CAAC;AACD,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,OAAO,CAAgB,CAAC;AAC1B,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,CAAY,CAAC;AACtB,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,CAAY,CAAC;AACtB,CAAC;AACD,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,CAAa,CAAC;AACvB,CAAC;AACD,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,CAAc,CAAC;AACxB,CAAC;AACD,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,OAAO,CAAkB,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@loop-engine/core",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "Domain model types for the Loop Engine - zero dependencies",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "dependencies": {},
18
+ "files": [
19
+ "dist/",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "test": "vitest run"
27
+ }
28
+ }