johankit-runtime 0.0.2 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +93 -115
  2. package/dist/src/app.d.ts +7 -0
  3. package/dist/src/app.d.ts.map +1 -0
  4. package/dist/src/app.js +18 -0
  5. package/dist/src/app.js.map +1 -0
  6. package/dist/src/core/cache.d.ts +6 -0
  7. package/dist/src/core/cache.d.ts.map +1 -0
  8. package/dist/src/core/cache.js +18 -0
  9. package/dist/src/core/cache.js.map +1 -0
  10. package/dist/src/core/conditions/resolver.d.ts +2 -0
  11. package/dist/src/core/conditions/resolver.d.ts.map +1 -0
  12. package/dist/src/core/conditions/resolver.js +20 -0
  13. package/dist/src/core/conditions/resolver.js.map +1 -0
  14. package/dist/src/core/config-loader.d.ts +2 -0
  15. package/dist/src/core/config-loader.d.ts.map +1 -0
  16. package/dist/src/core/config-loader.js +18 -0
  17. package/dist/src/core/config-loader.js.map +1 -0
  18. package/dist/src/core/context.d.ts +2 -0
  19. package/dist/src/core/context.d.ts.map +1 -0
  20. package/dist/src/core/context.js +5 -0
  21. package/dist/src/core/context.js.map +1 -0
  22. package/dist/src/core/discovery.d.ts +4 -0
  23. package/dist/src/core/discovery.d.ts.map +1 -0
  24. package/dist/src/core/discovery.js +6 -0
  25. package/dist/src/core/discovery.js.map +1 -0
  26. package/dist/src/core/event/dispatch.d.ts +2 -0
  27. package/dist/src/core/event/dispatch.d.ts.map +1 -0
  28. package/dist/src/core/event/dispatch.js +30 -0
  29. package/dist/src/core/event/dispatch.js.map +1 -0
  30. package/dist/src/core/mcp/http-server.d.ts +11 -0
  31. package/dist/src/core/mcp/http-server.d.ts.map +1 -0
  32. package/dist/src/core/mcp/http-server.js +48 -0
  33. package/dist/src/core/mcp/http-server.js.map +1 -0
  34. package/dist/src/core/mcp/tools-mcp.d.ts +14 -0
  35. package/dist/src/core/mcp/tools-mcp.d.ts.map +1 -0
  36. package/dist/src/core/mcp/tools-mcp.js +55 -0
  37. package/dist/src/core/mcp/tools-mcp.js.map +1 -0
  38. package/dist/src/core/middleware/run.d.ts +3 -0
  39. package/dist/src/core/middleware/run.d.ts.map +1 -0
  40. package/dist/src/core/middleware/run.js +39 -0
  41. package/dist/src/core/middleware/run.js.map +1 -0
  42. package/dist/src/core/package.d.ts +8 -0
  43. package/dist/src/core/package.d.ts.map +1 -0
  44. package/dist/src/core/package.js +68 -0
  45. package/dist/src/core/package.js.map +1 -0
  46. package/dist/src/core/parse/cognites.d.ts +5 -0
  47. package/dist/src/core/parse/cognites.d.ts.map +1 -0
  48. package/{src → dist/src}/core/parse/cognites.js +7 -10
  49. package/dist/src/core/parse/cognites.js.map +1 -0
  50. package/dist/src/core/parse/hooks.d.ts +10 -0
  51. package/dist/src/core/parse/hooks.d.ts.map +1 -0
  52. package/dist/src/core/parse/hooks.js +31 -0
  53. package/dist/src/core/parse/hooks.js.map +1 -0
  54. package/dist/src/core/parse/middleware.d.ts +6 -0
  55. package/dist/src/core/parse/middleware.d.ts.map +1 -0
  56. package/{src → dist/src}/core/parse/middleware.js +9 -14
  57. package/dist/src/core/parse/middleware.js.map +1 -0
  58. package/dist/src/core/parse/predicates.d.ts +5 -0
  59. package/dist/src/core/parse/predicates.d.ts.map +1 -0
  60. package/{src → dist/src}/core/parse/predicates.js +9 -10
  61. package/dist/src/core/parse/predicates.js.map +1 -0
  62. package/dist/src/core/parse/routes.d.ts +6 -0
  63. package/dist/src/core/parse/routes.d.ts.map +1 -0
  64. package/{src → dist/src}/core/parse/routes.js +12 -17
  65. package/dist/src/core/parse/routes.js.map +1 -0
  66. package/dist/src/core/parse/tools.d.ts +12 -0
  67. package/dist/src/core/parse/tools.d.ts.map +1 -0
  68. package/dist/src/core/parse/tools.js +77 -0
  69. package/dist/src/core/parse/tools.js.map +1 -0
  70. package/dist/src/core/register/decorators.d.ts +7 -0
  71. package/dist/src/core/register/decorators.d.ts.map +1 -0
  72. package/dist/src/core/register/decorators.js +114 -0
  73. package/dist/src/core/register/decorators.js.map +1 -0
  74. package/dist/src/core/register/decorators.test.d.ts +2 -0
  75. package/dist/src/core/register/decorators.test.d.ts.map +1 -0
  76. package/dist/src/core/register/decorators.test.js +17 -0
  77. package/dist/src/core/register/decorators.test.js.map +1 -0
  78. package/dist/src/core/register.d.ts +2 -0
  79. package/dist/src/core/register.d.ts.map +1 -0
  80. package/dist/src/core/register.js +12 -0
  81. package/dist/src/core/register.js.map +1 -0
  82. package/dist/src/core/routes.d.ts +2 -0
  83. package/dist/src/core/routes.d.ts.map +1 -0
  84. package/dist/src/core/routes.js +65 -0
  85. package/dist/src/core/routes.js.map +1 -0
  86. package/dist/src/core/schema/export.d.ts +5 -0
  87. package/dist/src/core/schema/export.d.ts.map +1 -0
  88. package/dist/src/core/schema/export.js +15 -0
  89. package/dist/src/core/schema/export.js.map +1 -0
  90. package/dist/src/core/tools/capabilities.d.ts +2 -0
  91. package/dist/src/core/tools/capabilities.d.ts.map +1 -0
  92. package/dist/src/core/tools/capabilities.js +11 -0
  93. package/dist/src/core/tools/capabilities.js.map +1 -0
  94. package/dist/src/core/tools/lifecycle.d.ts +2 -0
  95. package/dist/src/core/tools/lifecycle.d.ts.map +1 -0
  96. package/dist/src/core/tools/lifecycle.js +6 -0
  97. package/dist/src/core/tools/lifecycle.js.map +1 -0
  98. package/dist/src/core/tools/middleware.d.ts +2 -0
  99. package/dist/src/core/tools/middleware.d.ts.map +1 -0
  100. package/dist/src/core/tools/middleware.js +7 -0
  101. package/dist/src/core/tools/middleware.js.map +1 -0
  102. package/dist/src/core/wiring.d.ts +2 -0
  103. package/dist/src/core/wiring.d.ts.map +1 -0
  104. package/dist/src/core/wiring.js +8 -0
  105. package/dist/src/core/wiring.js.map +1 -0
  106. package/dist/src/index.d.ts +5 -0
  107. package/dist/src/index.d.ts.map +1 -0
  108. package/dist/src/index.js +40 -0
  109. package/dist/src/index.js.map +1 -0
  110. package/dist/src/server.d.ts +2 -0
  111. package/dist/src/server.d.ts.map +1 -0
  112. package/dist/src/server.js +19 -0
  113. package/dist/src/server.js.map +1 -0
  114. package/dist/src/types.d.ts +87 -0
  115. package/dist/src/types.d.ts.map +1 -0
  116. package/dist/src/types.js +3 -0
  117. package/dist/src/types.js.map +1 -0
  118. package/dist/tests/cognites.test.js +21 -0
  119. package/dist/tests/dispatch.test.js +73 -0
  120. package/dist/tests/hooks.test.js +31 -0
  121. package/dist/tests/middleware.test.js +19 -0
  122. package/dist/tests/predicates.test.js +20 -0
  123. package/dist/tests/routes.test.js +26 -0
  124. package/dist/tests/tools.test.js +38 -0
  125. package/package.json +13 -12
  126. package/src/app.ts +0 -18
  127. package/src/core/event/dispatch.js +0 -31
  128. package/src/core/mcp/http-server.js +0 -52
  129. package/src/core/mcp/tools-mcp.js +0 -50
  130. package/src/core/package.js +0 -79
  131. package/src/core/parse/hooks.js +0 -37
  132. package/src/core/parse/tools.js +0 -82
  133. package/src/core/register/decorators.js +0 -150
  134. package/src/core/register/decorators.test.js +0 -13
  135. package/src/core/register.js +0 -37
  136. package/src/core/routes.js +0 -89
  137. package/src/index.ts +0 -42
  138. package/src/server.ts +0 -15
  139. package/src/types.ts +0 -104
package/README.md CHANGED
@@ -1,29 +1,52 @@
1
1
  # Johankit Runtime
2
2
 
3
- A modular runtime built around **events**, **capabilities**, and **contracts**.
4
- It allows systems to grow by composition instead of coupling, using self-contained packages that are discovered and wired automatically.
3
+ Johankit Runtime is a modular, event-driven execution runtime built around **packages**, **events**, **routes**, **tools**, and **conditions**.
5
4
 
6
- This project is not a framework in the traditional sense.
7
- It is an **execution model**.
5
+ It is not a framework in the traditional sense. It is an **execution model** designed to let systems grow by composition instead of coupling.
8
6
 
9
7
  ---
10
8
 
11
- ## Why This Exists
9
+ ## Why Johankit
12
10
 
13
- Most systems grow by accumulating integrations:
14
- - interfaces
15
- - protocols
16
- - adapters
17
- - glue code
11
+ Most back-end systems evolve by accumulating:
18
12
 
19
- Johankit Runtime approaches this differently:
13
+ * integrations
14
+ * adapters
15
+ * glue code
16
+ * shared abstractions
20
17
 
21
- > Everything is a **package**.
22
- > Everything meaningful is an **event**, a **route**, or a **callable action**.
18
+ Johankit approaches this differently:
23
19
 
24
- No central registry.
25
- No hard dependencies between packages.
26
- No shared business logic.
20
+ * Everything is a **package**
21
+ * Everything meaningful is an **event**, **route**, or **tool**
22
+ * There is no central registry
23
+ * There are no hard dependencies between packages
24
+
25
+ Packages declare behavior explicitly and are discovered automatically at runtime.
26
+
27
+ ---
28
+
29
+ ## Installation
30
+
31
+ ```
32
+ npm install johankit-runtime
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Basic Usage
38
+
39
+ ```ts
40
+ import { bootstrap, dispatchEvent } from 'johankit-runtime'
41
+
42
+ await bootstrap({
43
+ workspace: './packages',
44
+ http: { enabled: true },
45
+ mcp: { enabled: true }
46
+ })
47
+
48
+ await dispatchEvent('user_created', { id: 1 })
49
+ ```
27
50
 
28
51
  ---
29
52
 
@@ -31,15 +54,16 @@ No shared business logic.
31
54
 
32
55
  ### Packages
33
56
 
34
- A package is an isolated unit of behavior living inside a workspace directory.
57
+ A package is an isolated unit of behavior located inside the workspace directory.
35
58
 
36
59
  A package may declare:
37
- - routes
38
- - event hooks
39
- - callable tools
40
- - predicates
41
- - middleware
42
- - startup logic
60
+
61
+ * event hooks
62
+ * HTTP routes
63
+ * tools (callable actions)
64
+ * predicates
65
+ * middleware
66
+ * startup logic
43
67
 
44
68
  Anything not explicitly declared is ignored.
45
69
 
@@ -48,10 +72,11 @@ Anything not explicitly declared is ignored.
48
72
  ### Discovery
49
73
 
50
74
  At startup, the runtime:
51
- 1. Scans the workspace
52
- 2. Loads packages
53
- 3. Inspects exported functions
54
- 4. Registers only what is explicitly annotated
75
+
76
+ 1. Resolves the workspace path
77
+ 2. Scans all package folders
78
+ 3. Loads JavaScript files
79
+ 4. Registers only annotated functions
55
80
 
56
81
  There is no manual wiring.
57
82
 
@@ -59,29 +84,26 @@ There is no manual wiring.
59
84
 
60
85
  ### Declarative Annotations
61
86
 
62
- Behavior is declared using structured comments.
87
+ Behavior is declared using JSDoc-style annotations.
63
88
 
64
- **Important rule: annotations must be inside the function body.**
89
+ **Important rule:**
90
+ Annotations **must be inside the function body**.
65
91
 
66
- This is intentional.
92
+ Example:
67
93
 
68
94
  ```js
69
95
  function example() {
70
96
  /**
71
- * @register_hook something
97
+ * @register_hook user_created
72
98
  */
73
99
  }
74
- ````
75
-
76
- Annotations outside the function will not be detected.
100
+ ```
77
101
 
78
- This makes annotations part of the behavior, not part of the language.
102
+ Annotations outside the function are intentionally ignored.
79
103
 
80
104
  ---
81
105
 
82
- ## Execution Primitives
83
-
84
- ### Events (Hooks)
106
+ ## Events (Hooks)
85
107
 
86
108
  Events represent something that happened.
87
109
 
@@ -94,19 +116,20 @@ function enrich(payload) {
94
116
  }
95
117
  ```
96
118
 
97
- * Events are broadcast to all packages
119
+ Characteristics:
120
+
98
121
  * Hooks run sequentially
99
122
  * Returned values replace the payload
100
123
  * `null` or `undefined` are ignored
101
124
  * Failures do not stop execution
102
125
 
103
- Events are **data pipelines**, not notifications.
126
+ Events act as **data pipelines**, not notifications.
104
127
 
105
128
  ---
106
129
 
107
- ### Routes
130
+ ## Routes
108
131
 
109
- Routes expose request handlers automatically.
132
+ Routes expose HTTP handlers automatically.
110
133
 
111
134
  ```js
112
135
  function status() {
@@ -118,11 +141,15 @@ function status() {
118
141
  }
119
142
  ```
120
143
 
121
- Routes are namespaced by package name and require no manual registration.
144
+ Routes are automatically namespaced by package name:
145
+
146
+ ```
147
+ /your-package/status
148
+ ```
122
149
 
123
150
  ---
124
151
 
125
- ### Tools
152
+ ## Tools
126
153
 
127
154
  Tools are structured, callable actions.
128
155
 
@@ -139,16 +166,16 @@ function calculate() {
139
166
 
140
167
  Tools:
141
168
 
142
- * expose their input schema
169
+ * expose input schemas
143
170
  * can be listed dynamically
144
171
  * can be invoked programmatically
145
- * can be exposed through control interfaces
172
+ * can be exposed via MCP or HTTP
146
173
 
147
174
  They are ideal for automation and orchestration.
148
175
 
149
176
  ---
150
177
 
151
- ### Predicates
178
+ ## Predicates
152
179
 
153
180
  Predicates are named boolean checks.
154
181
 
@@ -161,11 +188,11 @@ function isAdmin() {
161
188
  }
162
189
  ```
163
190
 
164
- They do nothing by themselves, but enable conditional execution elsewhere.
191
+ They enable conditional behavior elsewhere in the system.
165
192
 
166
193
  ---
167
194
 
168
- ### Middleware
195
+ ## Middleware
169
196
 
170
197
  Middleware can be conditionally enabled using predicates.
171
198
 
@@ -178,7 +205,7 @@ function guard() {
178
205
  }
179
206
  ```
180
207
 
181
- Only predicates that evaluate to `true` activate the middleware.
208
+ Only predicates that evaluate to true activate the middleware.
182
209
 
183
210
  ---
184
211
 
@@ -186,39 +213,19 @@ Only predicates that evaluate to `true` activate the middleware.
186
213
 
187
214
  Many declarations support optional conditions:
188
215
 
189
- ```text
190
- @only web
191
- @never mobile
192
- @when authenticated
193
- ```
194
-
195
- Conditions are **metadata**, not enforcement rules.
196
- They allow higher-level orchestration without hardcoding logic.
197
-
198
- ---
199
-
200
- ## Event Dispatching
201
-
202
- Events are dispatched explicitly:
203
-
204
- ```js
205
- dispatchEvent('user_created', payload)
206
- ```
216
+ * `@only web`
217
+ * `@never mobile`
218
+ * `@when authenticated`
207
219
 
208
- The runtime:
209
-
210
- * loads all packages
211
- * finds matching hooks
212
- * executes them safely
213
- * returns the final payload
220
+ Conditions are metadata, not enforcement rules.
214
221
 
215
- This enables cross-package collaboration without coupling.
222
+ They enable higher-level orchestration without hardcoding logic.
216
223
 
217
224
  ---
218
225
 
219
- ## Tool Control Interface (MCP-style)
226
+ ## MCP (Tool Control Interface)
220
227
 
221
- The runtime can expose tools through a standardized control surface.
228
+ Johankit can expose tools through an MCP-style control interface.
222
229
 
223
230
  Capabilities:
224
231
 
@@ -237,64 +244,35 @@ This makes the runtime suitable for:
237
244
 
238
245
  ## Bootstrapping
239
246
 
240
- The runtime is started by providing a workspace and optional interfaces.
241
-
242
- ```js
247
+ ```ts
243
248
  bootstrap({
244
249
  workspace: './packages',
245
- http: { enabled: true },
250
+ http: { enabled: true, port: 5040 },
246
251
  mcp: { enabled: true }
247
252
  })
248
253
  ```
249
254
 
250
255
  The bootstrap process:
251
256
 
252
- * resolves the workspace
253
257
  * loads all packages
254
- * initializes declared interfaces
255
- * returns references to running components
258
+ * initializes routes
259
+ * enables MCP interfaces
260
+ * starts HTTP servers if configured
256
261
 
257
262
  ---
258
263
 
259
264
  ## Design Principles
260
265
 
261
266
  * Explicit behavior over magic
262
- * Convention over configuration
267
+ * Composition over inheritance
263
268
  * Isolation between packages
264
269
  * Protocol-agnostic core
265
270
  * Graceful failure handling
266
- * Composition over inheritance
267
-
268
- ---
269
-
270
- ## What Fits Naturally
271
-
272
- Because the runtime is protocol-agnostic, it adapts well to:
273
-
274
- * real-time channels
275
- * background processing
276
- * schedulers
277
- * message streams
278
- * file watchers
279
- * control interfaces
280
- * agents and decision systems
281
-
282
- All of these are just **event translators**.
283
-
284
- ---
285
-
286
- ## What This Is Not
287
-
288
- * Not a monolithic framework
289
- * Not a dependency injection container
290
- * Not a plugin marketplace
291
- * Not a DSL
292
-
293
- It is a **runtime contract**.
294
271
 
295
272
  ---
296
273
 
297
274
  ## Project Status
298
275
 
299
- Early-stage, evolving by usage.
300
- APIs are intentionally minimal and may evolve as patterns emerge.
276
+ Early-stage and evolving through real usage.
277
+
278
+ APIs are intentionally minimal and may evolve as patterns emerge.
@@ -0,0 +1,7 @@
1
+ import { Application } from 'express';
2
+ type JohankitApp = Application & {
3
+ setup: () => Promise<void>;
4
+ };
5
+ declare const _default: JohankitApp;
6
+ export default _default;
7
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG9C,KAAK,WAAW,GAAG,WAAW,GAAG;IAC/B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B,CAAA;wBAYqB,WAAW;AAAjC,wBAAiC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const express_1 = __importDefault(require("express"));
7
+ const register_1 = require("./core/register");
8
+ const app = (0, express_1.default)();
9
+ app.setup = async () => {
10
+ try {
11
+ await (0, register_1.registerPackages)(app);
12
+ }
13
+ catch (error) {
14
+ console.log(`Error registering packages: ${error.message}`, 'error');
15
+ }
16
+ };
17
+ exports.default = app;
18
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8C;AAC9C,8CAAkD;AAMlD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAiB,CAEnC;AAAC,GAAmB,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;IACvC,IAAI,CAAC;QACH,MAAM,IAAA,2BAAgB,EAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;IACtE,CAAC;AACH,CAAC,CAAA;AAED,kBAAe,GAAkB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export function get(key: any): any;
2
+ export function set(key: any, value: any): void;
3
+ export function has(key: any): boolean;
4
+ export function invalidate(folderPath: any, parserName: any): void;
5
+ export function clear(): void;
6
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/core/cache.js"],"names":[],"mappings":"AAEA,mCAEC;AAED,gDAEC;AAED,uCAEC;AAED,mEAEC;AAED,8BAEC"}
@@ -0,0 +1,18 @@
1
+ const cache = new Map();
2
+ function get(key) {
3
+ return cache.get(key);
4
+ }
5
+ function set(key, value) {
6
+ cache.set(key, value);
7
+ }
8
+ function has(key) {
9
+ return cache.has(key);
10
+ }
11
+ function invalidate(folderPath, parserName) {
12
+ cache.delete(folderPath + parserName);
13
+ }
14
+ function clear() {
15
+ cache.clear();
16
+ }
17
+ module.exports = { get, set, has, invalidate, clear };
18
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/core/cache.js"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;AAExB,SAAS,GAAG,CAAC,GAAG;IACd,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,GAAG,CAAC,GAAG,EAAE,KAAK;IACrB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,GAAG,CAAC,GAAG;IACd,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CAAC,UAAU,EAAE,UAAU;IACxC,KAAK,CAAC,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,KAAK;IACZ,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export function resolveConditions(condition?: {}, context?: {}): Promise<boolean>;
2
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/core/conditions/resolver.js"],"names":[],"mappings":"AAAA,kFAWC"}
@@ -0,0 +1,20 @@
1
+ async function resolveConditions(condition = {}, context = {}) {
2
+ if (condition.only) {
3
+ for (const c of condition.only)
4
+ if (!context[c])
5
+ return false;
6
+ }
7
+ if (condition.never) {
8
+ for (const c of condition.never)
9
+ if (context[c])
10
+ return false;
11
+ }
12
+ if (condition.when) {
13
+ for (const c of condition.when)
14
+ if (!context[c])
15
+ return false;
16
+ }
17
+ return true;
18
+ }
19
+ module.exports = { resolveConditions };
20
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../src/core/conditions/resolver.js"],"names":[],"mappings":"AAAA,KAAK,UAAU,iBAAiB,CAAC,SAAS,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE;IAC3D,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;IAChE,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,KAAK;YAAE,IAAI,OAAO,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;IAChE,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export function loadPackageConfig(pkg: any): Promise<any>;
2
+ //# sourceMappingURL=config-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../src/core/config-loader.js"],"names":[],"mappings":"AAIA,0DAUC"}
@@ -0,0 +1,18 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const yaml = require('js-yaml');
4
+ async function loadPackageConfig(pkg) {
5
+ const ymlPath = path.join(__dirname, '..', 'packages', pkg.folder, 'agent.yml');
6
+ if (!fs.existsSync(ymlPath))
7
+ return pkg;
8
+ try {
9
+ const fileContents = fs.readFileSync(ymlPath, 'utf8');
10
+ pkg.config = yaml.load(fileContents);
11
+ }
12
+ catch (err) {
13
+ console.log(`Error reading YAML for ${pkg.folder}: ${err.message}`);
14
+ }
15
+ return pkg;
16
+ }
17
+ module.exports = { loadPackageConfig };
18
+ //# sourceMappingURL=config-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../../src/core/config-loader.js"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,KAAK,UAAU,iBAAiB,CAAC,GAAG;IAClC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtD,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export function createRuntimeContext(initial?: {}): {};
2
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/context.js"],"names":[],"mappings":"AAAA,uDAEC"}
@@ -0,0 +1,5 @@
1
+ function createRuntimeContext(initial = {}) {
2
+ return { ...initial };
3
+ }
4
+ module.exports = { createRuntimeContext };
5
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/context.js"],"names":[],"mappings":"AAAA,SAAS,oBAAoB,CAAC,OAAO,GAAG,EAAE;IACxC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export function discoverPackages(): Promise<{
2
+ folder: any;
3
+ }[]>;
4
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/core/discovery.js"],"names":[],"mappings":"AAEA;;KAEC"}
@@ -0,0 +1,6 @@
1
+ const { getPackages } = require('./package');
2
+ async function discoverPackages() {
3
+ return await getPackages();
4
+ }
5
+ module.exports = { discoverPackages };
6
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../src/core/discovery.js"],"names":[],"mappings":"AAAA,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAE7C,KAAK,UAAU,gBAAgB;IAC7B,OAAO,MAAM,WAAW,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export function dispatchEvent(eventName: any, payload: any, context?: {}): Promise<any>;
2
+ //# sourceMappingURL=dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../../src/core/event/dispatch.js"],"names":[],"mappings":"AAMA,wFAwBC"}
@@ -0,0 +1,30 @@
1
+ const { registerHooks } = require('../register/decorators');
2
+ const { getPackages } = require('../package');
3
+ const { resolveConditions } = require('../conditions/resolver');
4
+ const { createRuntimeContext } = require('../context');
5
+ const { resolveMiddlewares, runMiddlewares } = require('../middleware/run');
6
+ async function dispatchEvent(eventName, payload, context = createRuntimeContext()) {
7
+ const packages = await getPackages();
8
+ let finalResult = payload;
9
+ for (const pkg of packages) {
10
+ const hooks = await registerHooks(pkg.folder);
11
+ const relevant = hooks.filter(h => h.event === eventName);
12
+ if (relevant.length === 0)
13
+ continue;
14
+ const pkgContext = { ...context, pkg };
15
+ const middlewares = await resolveMiddlewares(pkg.folder, pkgContext);
16
+ for (const hook of relevant) {
17
+ const allowed = await resolveConditions(hook.condition || {}, pkgContext);
18
+ if (!allowed)
19
+ continue;
20
+ await runMiddlewares(middlewares, pkgContext, async () => {
21
+ const result = await hook.call(finalResult, pkgContext);
22
+ if (result !== undefined && result !== null)
23
+ finalResult = result;
24
+ });
25
+ }
26
+ }
27
+ return finalResult;
28
+ }
29
+ module.exports = { dispatchEvent };
30
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../../src/core/event/dispatch.js"],"names":[],"mappings":"AAAA,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC5D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAC9C,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,wBAAwB,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C;QACL,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,11 @@
1
+ export function createMcpHttpServer(options?: {}): Promise<{
2
+ app: import("express-serve-static-core").Express;
3
+ server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
4
+ mcp: {
5
+ protocol: string;
6
+ version: string;
7
+ listTools(context?: {}): any;
8
+ callTool(name: any, args: any, context?: {}): Promise<any>;
9
+ };
10
+ }>;
11
+ //# sourceMappingURL=http-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../../../../src/core/mcp/http-server.js"],"names":[],"mappings":"AAKA;;;;;;;;;GAkDC"}
@@ -0,0 +1,48 @@
1
+ const express = require('express');
2
+ const bodyParser = require('body-parser');
3
+ const { bootstrapMcp } = require('./tools-mcp');
4
+ const { createRuntimeContext } = require('../context');
5
+ async function createMcpHttpServer(options = {}) {
6
+ const app = express();
7
+ const port = options.port || 3333;
8
+ const workspace = options.workspace || process.env.PACKAGES_PATH;
9
+ if (!workspace) {
10
+ throw new Error('PACKAGES_PATH or workspace option is required');
11
+ }
12
+ const mcp = await bootstrapMcp(workspace);
13
+ app.use(bodyParser.json());
14
+ app.use((req, res, next) => {
15
+ req.runtimeContext = createRuntimeContext({ req, res });
16
+ next();
17
+ });
18
+ app.get('/mcp', (req, res) => {
19
+ res.json({ protocol: mcp.protocol, version: mcp.version });
20
+ });
21
+ app.get('/mcp/tools', async (req, res) => {
22
+ try {
23
+ res.json(mcp.listTools(req.runtimeContext));
24
+ }
25
+ catch (err) {
26
+ res.status(500).json({ error: err.message });
27
+ }
28
+ });
29
+ app.post('/mcp/call', async (req, res) => {
30
+ const { name, args } = req.body || {};
31
+ if (!name) {
32
+ return res.status(400).json({ error: 'Tool name is required' });
33
+ }
34
+ try {
35
+ const result = await mcp.callTool(name, args || {}, req.runtimeContext);
36
+ res.json({ result });
37
+ }
38
+ catch (err) {
39
+ res.status(500).json({ error: err.message });
40
+ }
41
+ });
42
+ const server = app.listen(port, () => {
43
+ console.log(`MCP HTTP server running on port ${port}`);
44
+ });
45
+ return { app, server, mcp };
46
+ }
47
+ module.exports = { createMcpHttpServer };
48
+ //# sourceMappingURL=http-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-server.js","sourceRoot":"","sources":["../../../../src/core/mcp/http-server.js"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC1C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAChD,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEvD,KAAK,UAAU,mBAAmB,CAAC,OAAO,GAAG,EAAE;IAC7C,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;IAClC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAEjE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,CAAC;IAE1C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3B,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,GAAG,CAAC,cAAc,GAAG,oBAAoB,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,EAAE,CAAC;IACT,CAAC,CAA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,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,mCAAmC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ export function loadMcpTools(agentFolder: any): Promise<any>;
2
+ export function createMcpServer(tools: any): {
3
+ protocol: string;
4
+ version: string;
5
+ listTools(context?: {}): any;
6
+ callTool(name: any, args: any, context?: {}): Promise<any>;
7
+ };
8
+ export function bootstrapMcp(agentFolder: any): Promise<{
9
+ protocol: string;
10
+ version: string;
11
+ listTools(context?: {}): any;
12
+ callTool(name: any, args: any, context?: {}): Promise<any>;
13
+ }>;
14
+ //# sourceMappingURL=tools-mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-mcp.d.ts","sourceRoot":"","sources":["../../../../src/core/mcp/tools-mcp.js"],"names":[],"mappings":"AAkCA,6DAGC;AAED;;;;;EAeC;AAED;;;;;GAGC"}