@typescript-agent-harness/core 0.15.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 +21 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +37 -0
- package/dist/context.js.map +1 -0
- package/dist/event-bus.d.ts +12 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +33 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/events.d.ts +38 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +11 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/runtime.d.ts +39 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +108 -0
- package/dist/runtime.js.map +1 -0
- package/dist/service.d.ts +21 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +20 -0
- package/dist/service.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 typescript-agent-harness 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,25 @@
|
|
|
1
|
+
import { EventBus } from "./event-bus.js";
|
|
2
|
+
import type { EventHandler, EventPayload, Unsubscribe } from "./events.js";
|
|
3
|
+
import { type ServiceKey } from "./service.js";
|
|
4
|
+
export interface Context {
|
|
5
|
+
readonly runtimeId: string;
|
|
6
|
+
get<T>(key: ServiceKey<T>): T;
|
|
7
|
+
tryGet<T>(key: ServiceKey<T>): T | undefined;
|
|
8
|
+
provide<T>(key: ServiceKey<T>, value: T): void;
|
|
9
|
+
emit<TName extends string>(type: TName, payload: EventPayload<TName>): Promise<void>;
|
|
10
|
+
on<TName extends string>(type: TName, handler: EventHandler<EventPayload<TName>>): Unsubscribe;
|
|
11
|
+
}
|
|
12
|
+
export declare class RuntimeContext implements Context {
|
|
13
|
+
readonly runtimeId: string;
|
|
14
|
+
private readonly bus;
|
|
15
|
+
private readonly services;
|
|
16
|
+
constructor(runtimeId: string, bus: EventBus);
|
|
17
|
+
get<T>(key: ServiceKey<T>): T;
|
|
18
|
+
tryGet<T>(key: ServiceKey<T>): T | undefined;
|
|
19
|
+
provide<T>(key: ServiceKey<T>, value: T): void;
|
|
20
|
+
emit<TName extends string>(type: TName, payload: EventPayload<TName>): Promise<void>;
|
|
21
|
+
on<TName extends string>(type: TName, handler: EventHandler<EventPayload<TName>>): Unsubscribe;
|
|
22
|
+
/** Internal: wipe service registry on stop. */
|
|
23
|
+
clearServices(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAE9B,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAE7C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAE/C,IAAI,CAAC,KAAK,SAAS,MAAM,EACvB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,EAAE,CAAC,KAAK,SAAS,MAAM,EACrB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GACzC,WAAW,CAAC;CAChB;AAED,qBAAa,cAAe,YAAW,OAAO;IAI1C,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;gBAG5C,SAAS,EAAE,MAAM,EACT,GAAG,EAAE,QAAQ;IAGhC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IAO7B,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAI5C,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAOxC,IAAI,CAAC,KAAK,SAAS,MAAM,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC;IAIhB,EAAE,CAAC,KAAK,SAAS,MAAM,EACrB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GACzC,WAAW;IAId,+CAA+C;IAC/C,aAAa,IAAI,IAAI;CAGtB"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EventBus } from "./event-bus.js";
|
|
2
|
+
import { ServiceAlreadyProvidedError, ServiceNotFoundError, } from "./service.js";
|
|
3
|
+
export class RuntimeContext {
|
|
4
|
+
runtimeId;
|
|
5
|
+
bus;
|
|
6
|
+
services = new Map();
|
|
7
|
+
constructor(runtimeId, bus) {
|
|
8
|
+
this.runtimeId = runtimeId;
|
|
9
|
+
this.bus = bus;
|
|
10
|
+
}
|
|
11
|
+
get(key) {
|
|
12
|
+
if (!this.services.has(key.id)) {
|
|
13
|
+
throw new ServiceNotFoundError(key.id);
|
|
14
|
+
}
|
|
15
|
+
return this.services.get(key.id);
|
|
16
|
+
}
|
|
17
|
+
tryGet(key) {
|
|
18
|
+
return this.services.get(key.id);
|
|
19
|
+
}
|
|
20
|
+
provide(key, value) {
|
|
21
|
+
if (this.services.has(key.id)) {
|
|
22
|
+
throw new ServiceAlreadyProvidedError(key.id);
|
|
23
|
+
}
|
|
24
|
+
this.services.set(key.id, value);
|
|
25
|
+
}
|
|
26
|
+
async emit(type, payload) {
|
|
27
|
+
await this.bus.emit(type, payload);
|
|
28
|
+
}
|
|
29
|
+
on(type, handler) {
|
|
30
|
+
return this.bus.on(type, handler);
|
|
31
|
+
}
|
|
32
|
+
/** Internal: wipe service registry on stop. */
|
|
33
|
+
clearServices() {
|
|
34
|
+
this.services.clear();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM1C,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,cAAc,CAAC;AAsBtB,MAAM,OAAO,cAAc;IAId;IACQ;IAJF,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEvD,YACW,SAAiB,EACT,GAAa;QADrB,cAAS,GAAT,SAAS,CAAQ;QACT,QAAG,GAAH,GAAG,CAAU;IAC7B,CAAC;IAEJ,GAAG,CAAI,GAAkB;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAM,CAAC;IACxC,CAAC;IAED,MAAM,CAAI,GAAkB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAkB,CAAC;IACpD,CAAC;IAED,OAAO,CAAI,GAAkB,EAAE,KAAQ;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,2BAA2B,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI,CACR,IAAW,EACX,OAA4B;QAE5B,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,EAAE,CACA,IAAW,EACX,OAA0C;QAE1C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,+CAA+C;IAC/C,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EventHandler, Unsubscribe } from "./events.js";
|
|
2
|
+
export declare class EventBus {
|
|
3
|
+
private readonly handlers;
|
|
4
|
+
on<TPayload = unknown>(event: string, handler: EventHandler<TPayload>): Unsubscribe;
|
|
5
|
+
/**
|
|
6
|
+
* Emit an event and await all handlers sequentially.
|
|
7
|
+
* Sequential await keeps plugin side-effects predictable in Phase 1.
|
|
8
|
+
*/
|
|
9
|
+
emit(event: string, payload?: unknown): Promise<void>;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IAEjE,EAAE,CAAC,QAAQ,GAAG,OAAO,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC9B,WAAW;IAgBd;;;OAGG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class EventBus {
|
|
2
|
+
handlers = new Map();
|
|
3
|
+
on(event, handler) {
|
|
4
|
+
let set = this.handlers.get(event);
|
|
5
|
+
if (!set) {
|
|
6
|
+
set = new Set();
|
|
7
|
+
this.handlers.set(event, set);
|
|
8
|
+
}
|
|
9
|
+
set.add(handler);
|
|
10
|
+
return () => {
|
|
11
|
+
set.delete(handler);
|
|
12
|
+
if (set.size === 0) {
|
|
13
|
+
this.handlers.delete(event);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Emit an event and await all handlers sequentially.
|
|
19
|
+
* Sequential await keeps plugin side-effects predictable in Phase 1.
|
|
20
|
+
*/
|
|
21
|
+
async emit(event, payload) {
|
|
22
|
+
const set = this.handlers.get(event);
|
|
23
|
+
if (!set || set.size === 0)
|
|
24
|
+
return;
|
|
25
|
+
for (const handler of [...set]) {
|
|
26
|
+
await handler(payload);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
this.handlers.clear();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACF,QAAQ,GAAG,IAAI,GAAG,EAA6B,CAAC;IAEjE,EAAE,CACA,KAAa,EACb,OAA+B;QAE/B,IAAI,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,OAAuB,CAAC,CAAC;QAEjC,OAAO,GAAG,EAAE;YACV,GAAI,CAAC,MAAM,CAAC,OAAuB,CAAC,CAAC;YACrC,IAAI,GAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,OAAiB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO;QAEnC,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type EventHandler<TPayload = unknown> = (payload: TPayload) => void | Promise<void>;
|
|
2
|
+
export type Unsubscribe = () => void;
|
|
3
|
+
export interface RuntimeEventMap {
|
|
4
|
+
"runtime.starting": {
|
|
5
|
+
runtimeId: string;
|
|
6
|
+
};
|
|
7
|
+
"runtime.started": {
|
|
8
|
+
runtimeId: string;
|
|
9
|
+
};
|
|
10
|
+
"runtime.stopping": {
|
|
11
|
+
runtimeId: string;
|
|
12
|
+
};
|
|
13
|
+
"runtime.stopped": {
|
|
14
|
+
runtimeId: string;
|
|
15
|
+
};
|
|
16
|
+
"plugin.setup": {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
"plugin.dispose": {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export type KnownEventName = keyof RuntimeEventMap;
|
|
24
|
+
export type EventPayload<TName extends string> = TName extends KnownEventName ? RuntimeEventMap[TName] : unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Discriminated runtime events used by emit().
|
|
27
|
+
* Built-in names are typed; custom names accept any payload.
|
|
28
|
+
*/
|
|
29
|
+
export type RuntimeEvent = {
|
|
30
|
+
[K in KnownEventName]: {
|
|
31
|
+
type: K;
|
|
32
|
+
payload: RuntimeEventMap[K];
|
|
33
|
+
};
|
|
34
|
+
}[KnownEventName] | {
|
|
35
|
+
type: string;
|
|
36
|
+
payload?: unknown;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,QAAQ,GAAG,OAAO,IAAI,CAC7C,OAAO,EAAE,QAAQ,KACd,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,iBAAiB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,kBAAkB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,iBAAiB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,gBAAgB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,YAAY,CAAC,KAAK,SAAS,MAAM,IAC3C,KAAK,SAAS,cAAc,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;KACG,CAAC,IAAI,cAAc,GAAG;QACrB,IAAI,EAAE,CAAC,CAAC;QACR,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;KAC7B;CACF,CAAC,cAAc,CAAC,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Runtime, type RuntimeOptions, type RuntimeState } from "./runtime.js";
|
|
2
|
+
export { type Context, RuntimeContext } from "./context.js";
|
|
3
|
+
export { type Plugin, type PluginFactory } from "./plugin.js";
|
|
4
|
+
export { createServiceKey, ServiceAlreadyProvidedError, ServiceNotFoundError, type ServiceKey, } from "./service.js";
|
|
5
|
+
export { EventBus } from "./event-bus.js";
|
|
6
|
+
export type { EventHandler, EventPayload, KnownEventName, RuntimeEvent, RuntimeEventMap, Unsubscribe, } from "./events.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,KAAK,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,UAAU,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Runtime } from "./runtime.js";
|
|
2
|
+
export { RuntimeContext } from "./context.js";
|
|
3
|
+
export {} from "./plugin.js";
|
|
4
|
+
export { createServiceKey, ServiceAlreadyProvidedError, ServiceNotFoundError, } from "./service.js";
|
|
5
|
+
export { EventBus } from "./event-bus.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA0C,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAgB,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAmC,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "./context.js";
|
|
2
|
+
/**
|
|
3
|
+
* Everything is a capability — and every capability is mounted as a Plugin.
|
|
4
|
+
*/
|
|
5
|
+
export interface Plugin {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
setup(ctx: Context): void | Promise<void>;
|
|
8
|
+
dispose?(): void | Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export type PluginFactory = () => Plugin;
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Context } from "./context.js";
|
|
2
|
+
import type { EventHandler, EventPayload, Unsubscribe } from "./events.js";
|
|
3
|
+
import type { Plugin } from "./plugin.js";
|
|
4
|
+
import type { ServiceKey } from "./service.js";
|
|
5
|
+
export type RuntimeState = "idle" | "starting" | "running" | "stopping" | "stopped";
|
|
6
|
+
export interface RuntimeOptions {
|
|
7
|
+
/** Stable id for observability; random uuid if omitted. */
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Agent Runtime — first-class citizen.
|
|
12
|
+
*
|
|
13
|
+
* Plugins mount capabilities into a shared Context.
|
|
14
|
+
* Nothing privileged: LLM, Tools, Session, Storage are all plugins.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Runtime {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
private readonly bus;
|
|
19
|
+
private readonly plugins;
|
|
20
|
+
private readonly pluginNames;
|
|
21
|
+
private ctx;
|
|
22
|
+
private state;
|
|
23
|
+
constructor(options?: RuntimeOptions);
|
|
24
|
+
getState(): RuntimeState;
|
|
25
|
+
/**
|
|
26
|
+
* Register a plugin. Must be called before start().
|
|
27
|
+
* Duplicate names are rejected.
|
|
28
|
+
*/
|
|
29
|
+
use(plugin: Plugin): this;
|
|
30
|
+
/** Runtime-level subscribe (same bus as Context). */
|
|
31
|
+
on<TName extends string>(type: TName, handler: EventHandler<EventPayload<TName>>): Unsubscribe;
|
|
32
|
+
/** Convenience: resolve a service after start. */
|
|
33
|
+
get<T>(key: ServiceKey<T>): T;
|
|
34
|
+
context(): Context;
|
|
35
|
+
start(): Promise<void>;
|
|
36
|
+
stop(): Promise<void>;
|
|
37
|
+
private assertRunning;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEpF,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AASD;;;;;GAKG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,KAAK,CAAwB;gBAEzB,OAAO,GAAE,cAAmB;IAKxC,QAAQ,IAAI,YAAY;IAIxB;;;OAGG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAczB,qDAAqD;IACrD,EAAE,CAAC,KAAK,SAAS,MAAM,EACrB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,GACzC,WAAW;IAId,kDAAkD;IAClD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IAK7B,OAAO,IAAI,OAAO;IAIZ,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB3B,OAAO,CAAC,aAAa;CAKtB"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { RuntimeContext } from "./context.js";
|
|
2
|
+
import { EventBus } from "./event-bus.js";
|
|
3
|
+
let runtimeSeq = 0;
|
|
4
|
+
function nextRuntimeId() {
|
|
5
|
+
runtimeSeq += 1;
|
|
6
|
+
return `runtime_${runtimeSeq}_${Date.now().toString(36)}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Agent Runtime — first-class citizen.
|
|
10
|
+
*
|
|
11
|
+
* Plugins mount capabilities into a shared Context.
|
|
12
|
+
* Nothing privileged: LLM, Tools, Session, Storage are all plugins.
|
|
13
|
+
*/
|
|
14
|
+
export class Runtime {
|
|
15
|
+
id;
|
|
16
|
+
bus = new EventBus();
|
|
17
|
+
plugins = [];
|
|
18
|
+
pluginNames = new Set();
|
|
19
|
+
ctx;
|
|
20
|
+
state = "idle";
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.id = options.id ?? nextRuntimeId();
|
|
23
|
+
this.ctx = new RuntimeContext(this.id, this.bus);
|
|
24
|
+
}
|
|
25
|
+
getState() {
|
|
26
|
+
return this.state;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a plugin. Must be called before start().
|
|
30
|
+
* Duplicate names are rejected.
|
|
31
|
+
*/
|
|
32
|
+
use(plugin) {
|
|
33
|
+
if (this.state !== "idle") {
|
|
34
|
+
throw new Error(`Cannot register plugin "${plugin.name}" after runtime has started (state=${this.state})`);
|
|
35
|
+
}
|
|
36
|
+
if (this.pluginNames.has(plugin.name)) {
|
|
37
|
+
throw new Error(`Duplicate plugin name: ${plugin.name}`);
|
|
38
|
+
}
|
|
39
|
+
this.pluginNames.add(plugin.name);
|
|
40
|
+
this.plugins.push(plugin);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/** Runtime-level subscribe (same bus as Context). */
|
|
44
|
+
on(type, handler) {
|
|
45
|
+
return this.bus.on(type, handler);
|
|
46
|
+
}
|
|
47
|
+
/** Convenience: resolve a service after start. */
|
|
48
|
+
get(key) {
|
|
49
|
+
this.assertRunning();
|
|
50
|
+
return this.ctx.get(key);
|
|
51
|
+
}
|
|
52
|
+
context() {
|
|
53
|
+
return this.ctx;
|
|
54
|
+
}
|
|
55
|
+
async start() {
|
|
56
|
+
if (this.state === "running")
|
|
57
|
+
return;
|
|
58
|
+
if (this.state !== "idle" && this.state !== "stopped") {
|
|
59
|
+
throw new Error(`Cannot start runtime from state=${this.state}`);
|
|
60
|
+
}
|
|
61
|
+
// Fresh context if restarting after stop
|
|
62
|
+
if (this.state === "stopped") {
|
|
63
|
+
this.bus.clear();
|
|
64
|
+
this.ctx = new RuntimeContext(this.id, this.bus);
|
|
65
|
+
}
|
|
66
|
+
this.state = "starting";
|
|
67
|
+
await this.bus.emit("runtime.starting", { runtimeId: this.id });
|
|
68
|
+
try {
|
|
69
|
+
for (const plugin of this.plugins) {
|
|
70
|
+
await plugin.setup(this.ctx);
|
|
71
|
+
await this.bus.emit("plugin.setup", { name: plugin.name });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
this.state = "idle";
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
this.state = "running";
|
|
79
|
+
await this.bus.emit("runtime.started", { runtimeId: this.id });
|
|
80
|
+
}
|
|
81
|
+
async stop() {
|
|
82
|
+
if (this.state === "stopped" || this.state === "idle")
|
|
83
|
+
return;
|
|
84
|
+
if (this.state !== "running") {
|
|
85
|
+
throw new Error(`Cannot stop runtime from state=${this.state}`);
|
|
86
|
+
}
|
|
87
|
+
this.state = "stopping";
|
|
88
|
+
await this.bus.emit("runtime.stopping", { runtimeId: this.id });
|
|
89
|
+
// Dispose in reverse registration order
|
|
90
|
+
for (const plugin of [...this.plugins].reverse()) {
|
|
91
|
+
if (plugin.dispose) {
|
|
92
|
+
await plugin.dispose();
|
|
93
|
+
}
|
|
94
|
+
await this.bus.emit("plugin.dispose", { name: plugin.name });
|
|
95
|
+
}
|
|
96
|
+
this.ctx.clearServices();
|
|
97
|
+
this.state = "stopped";
|
|
98
|
+
await this.bus.emit("runtime.stopped", { runtimeId: this.id });
|
|
99
|
+
// Clear after stopped so observers can still hear the final event.
|
|
100
|
+
this.bus.clear();
|
|
101
|
+
}
|
|
102
|
+
assertRunning() {
|
|
103
|
+
if (this.state !== "running") {
|
|
104
|
+
throw new Error(`Runtime is not running (state=${this.state})`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAA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AiB,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/D,mEAAmE;QACnE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;IAEO,aAAa;QACnB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed service keys. Plugins provide/consume capabilities without importing each other.
|
|
3
|
+
*
|
|
4
|
+
* const LLM = createServiceKey<LLMService>("llm");
|
|
5
|
+
* ctx.provide(LLM, impl);
|
|
6
|
+
* const llm = ctx.get(LLM);
|
|
7
|
+
*/
|
|
8
|
+
export interface ServiceKey<T> {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly __type?: T;
|
|
11
|
+
}
|
|
12
|
+
export declare function createServiceKey<T>(id: string): ServiceKey<T>;
|
|
13
|
+
export declare class ServiceNotFoundError extends Error {
|
|
14
|
+
readonly keyId: string;
|
|
15
|
+
constructor(keyId: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class ServiceAlreadyProvidedError extends Error {
|
|
18
|
+
readonly keyId: string;
|
|
19
|
+
constructor(keyId: string);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAE7D;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAInC;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAInC"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function createServiceKey(id) {
|
|
2
|
+
return { id };
|
|
3
|
+
}
|
|
4
|
+
export class ServiceNotFoundError extends Error {
|
|
5
|
+
keyId;
|
|
6
|
+
constructor(keyId) {
|
|
7
|
+
super(`Service not found: ${keyId}`);
|
|
8
|
+
this.keyId = keyId;
|
|
9
|
+
this.name = "ServiceNotFoundError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ServiceAlreadyProvidedError extends Error {
|
|
13
|
+
keyId;
|
|
14
|
+
constructor(keyId) {
|
|
15
|
+
super(`Service already provided: ${keyId}`);
|
|
16
|
+
this.keyId = keyId;
|
|
17
|
+
this.name = "ServiceAlreadyProvidedError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,gBAAgB,CAAI,EAAU;IAC5C,OAAO,EAAE,EAAE,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACxB;IAArB,YAAqB,KAAa;QAChC,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;QADlB,UAAK,GAAL,KAAK,CAAQ;QAEhC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAC/B;IAArB,YAAqB,KAAa;QAChC,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;QADzB,UAAK,GAAL,KAAK,CAAQ;QAEhC,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typescript-agent-harness/core",
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "Agent Runtime core: Runtime, Plugin, Context, Service, EventBus",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.9.2"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/MichaelVendor/typescript-agent-harness.git",
|
|
31
|
+
"directory": "packages/core"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://MichaelVendor.github.io/typescript-agent-harness/",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/MichaelVendor/typescript-agent-harness/issues"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"test": "node --test --experimental-strip-types test/*.test.ts"
|
|
41
|
+
}
|
|
42
|
+
}
|