@orgloop/core 0.1.5 → 0.1.7
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/README.md +51 -17
- package/dist/engine.d.ts +12 -26
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +61 -448
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts +19 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +114 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +5 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +15 -5
- package/dist/logger.js.map +1 -1
- package/dist/module-instance.d.ts +76 -0
- package/dist/module-instance.d.ts.map +1 -0
- package/dist/module-instance.js +185 -0
- package/dist/module-instance.js.map +1 -0
- package/dist/prompt.d.ts +20 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +35 -0
- package/dist/prompt.js.map +1 -0
- package/dist/registry.d.ts +23 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +42 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime.d.ts +81 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +522 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scheduler.d.ts +11 -2
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +44 -6
- package/dist/scheduler.js.map +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/transform.js +45 -18
- package/dist/transform.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @orgloop/core
|
|
2
2
|
|
|
3
|
-
OrgLoop runtime engine -- library-first event routing for autonomous AI organizations.
|
|
3
|
+
OrgLoop runtime engine -- library-first event routing for autonomous AI organizations. Multi-module runtime with independent module lifecycle, shared infrastructure, and backward-compatible single-module API.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -10,34 +10,67 @@ npm install @orgloop/core
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
### Multi-module (Runtime)
|
|
14
|
+
|
|
13
15
|
```typescript
|
|
14
|
-
import {
|
|
16
|
+
import { Runtime, InMemoryBus } from '@orgloop/core';
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const runtime = new Runtime({ bus: new InMemoryBus() });
|
|
19
|
+
await runtime.start();
|
|
18
20
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// Load modules dynamically
|
|
22
|
+
await runtime.loadModule(
|
|
23
|
+
{ name: 'engineering', sources: [...], actors: [...], routes: [...], transforms: [], loggers: [] },
|
|
24
|
+
{ sources: mySourcesMap, actors: myActorsMap }
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// Load more modules without restarting
|
|
28
|
+
await runtime.loadModule(anotherModuleConfig, anotherConnectors);
|
|
29
|
+
|
|
30
|
+
// Manage modules at runtime
|
|
31
|
+
await runtime.reloadModule('engineering');
|
|
32
|
+
await runtime.unloadModule('engineering');
|
|
33
|
+
|
|
34
|
+
await runtime.stop();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Single-module (OrgLoop wrapper)
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
```typescript
|
|
40
|
+
import { OrgLoop, loadConfig } from '@orgloop/core';
|
|
41
|
+
|
|
42
|
+
// Backward-compatible API -- creates a Runtime with one "default" module
|
|
43
|
+
const config = await loadConfig('./orgloop.yaml');
|
|
44
|
+
const loop = new OrgLoop(config, {
|
|
45
|
+
sources: mySourcesMap,
|
|
46
|
+
actors: myActorsMap,
|
|
47
|
+
});
|
|
28
48
|
|
|
29
|
-
|
|
30
|
-
await
|
|
49
|
+
await loop.start();
|
|
50
|
+
await loop.stop();
|
|
31
51
|
```
|
|
32
52
|
|
|
33
53
|
## API
|
|
34
54
|
|
|
35
|
-
###
|
|
55
|
+
### Runtime (multi-module)
|
|
36
56
|
|
|
37
|
-
- `
|
|
57
|
+
- `Runtime` -- multi-module runtime class (extends EventEmitter)
|
|
58
|
+
- `RuntimeOptions` -- runtime constructor options (bus, httpPort, circuitBreaker, dataDir)
|
|
59
|
+
- `LoadModuleOptions` -- options for loadModule() (sources, actors, transforms, loggers, checkpointStore)
|
|
60
|
+
|
|
61
|
+
### Engine (single-module wrapper)
|
|
62
|
+
|
|
63
|
+
- `OrgLoop` -- backward-compatible wrapper around Runtime (extends EventEmitter)
|
|
38
64
|
- `OrgLoopOptions` -- engine constructor options
|
|
39
65
|
- `EngineStatus` -- runtime status type
|
|
40
66
|
|
|
67
|
+
### Module lifecycle
|
|
68
|
+
|
|
69
|
+
- `ModuleInstance` -- per-module resource container with lifecycle (loading/active/unloading/removed)
|
|
70
|
+
- `ModuleRegistry` -- singleton module name registry
|
|
71
|
+
- `ModuleConfig` -- module configuration type
|
|
72
|
+
- `ModuleContext` -- module-scoped context
|
|
73
|
+
|
|
41
74
|
### Config
|
|
42
75
|
|
|
43
76
|
- `loadConfig(path, options?)` -- load and validate YAML config with env var substitution
|
|
@@ -62,11 +95,12 @@ await engine.stop();
|
|
|
62
95
|
|
|
63
96
|
- `Scheduler` -- manages poll intervals with graceful start/stop
|
|
64
97
|
- `LoggerManager` -- fan-out to multiple loggers, error-isolated
|
|
65
|
-
- `WebhookServer` -- HTTP server for webhook
|
|
98
|
+
- `WebhookServer` -- HTTP server for webhook sources and control API
|
|
66
99
|
|
|
67
100
|
### Errors
|
|
68
101
|
|
|
69
102
|
- `OrgLoopError`, `ConfigError`, `ConnectorError`, `TransformError`, `DeliveryError`, `SchemaError`
|
|
103
|
+
- `ModuleConflictError`, `ModuleNotFoundError`, `RuntimeError`
|
|
70
104
|
|
|
71
105
|
## Documentation
|
|
72
106
|
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OrgLoop —
|
|
2
|
+
* OrgLoop — backward-compatible wrapper around Runtime.
|
|
3
3
|
*
|
|
4
4
|
* Library-first API:
|
|
5
5
|
* const loop = new OrgLoop(config);
|
|
6
6
|
* await loop.start();
|
|
7
7
|
* await loop.stop();
|
|
8
|
+
*
|
|
9
|
+
* Internally delegates to a Runtime instance, converting the flat
|
|
10
|
+
* OrgLoopConfig into a single module. Preserves the original public API
|
|
11
|
+
* for existing callers and tests.
|
|
8
12
|
*/
|
|
9
13
|
import { EventEmitter } from 'node:events';
|
|
10
|
-
import type { ActorConnector, Logger, OrgLoopConfig, OrgLoopEvent, SourceConnector, SourceHealthState } from '@orgloop/sdk';
|
|
11
|
-
import type { Transform } from '@orgloop/sdk';
|
|
14
|
+
import type { ActorConnector, Logger, OrgLoopConfig, OrgLoopEvent, SourceConnector, SourceHealthState, Transform } from '@orgloop/sdk';
|
|
12
15
|
import type { EventBus } from './bus.js';
|
|
13
16
|
import { LoggerManager } from './logger.js';
|
|
14
17
|
import type { CheckpointStore } from './store.js';
|
|
@@ -57,22 +60,9 @@ export interface OrgLoopEvents {
|
|
|
57
60
|
}
|
|
58
61
|
export declare class OrgLoop extends EventEmitter {
|
|
59
62
|
private readonly config;
|
|
60
|
-
private readonly
|
|
61
|
-
private readonly
|
|
62
|
-
private readonly
|
|
63
|
-
private readonly resolvedLoggers;
|
|
64
|
-
private readonly bus;
|
|
65
|
-
private readonly checkpointStore;
|
|
66
|
-
private readonly loggerManager;
|
|
67
|
-
private readonly scheduler;
|
|
68
|
-
private readonly httpPort;
|
|
69
|
-
private webhookServer;
|
|
70
|
-
private readonly webhookSources;
|
|
71
|
-
private running;
|
|
72
|
-
private startedAt;
|
|
73
|
-
private readonly healthStates;
|
|
74
|
-
private readonly circuitBreakerOpts;
|
|
75
|
-
private readonly circuitRetryTimers;
|
|
63
|
+
private readonly runtime;
|
|
64
|
+
private readonly moduleConfig;
|
|
65
|
+
private readonly loadOptions;
|
|
76
66
|
constructor(config: OrgLoopConfig, options?: OrgLoopOptions);
|
|
77
67
|
/**
|
|
78
68
|
* Start the engine: initialize connectors, start scheduler, begin processing.
|
|
@@ -96,14 +86,10 @@ export declare class OrgLoop extends EventEmitter {
|
|
|
96
86
|
* Get health state for all sources.
|
|
97
87
|
*/
|
|
98
88
|
health(): SourceHealthState[];
|
|
99
|
-
private pollSource;
|
|
100
89
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
90
|
+
* Internal: poll a single source (used by health-tracking tests).
|
|
91
|
+
* @internal
|
|
103
92
|
*/
|
|
104
|
-
private
|
|
105
|
-
private processEvent;
|
|
106
|
-
private deliverToActor;
|
|
107
|
-
private emitLog;
|
|
93
|
+
private pollSource;
|
|
108
94
|
}
|
|
109
95
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACX,cAAc,EACd,MAAM,EACN,aAAa,EACb,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,MAAM,WAAW,2BAA2B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