@yesod/core 0.0.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.cjs +122 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +146 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
EventBus: () => EventBus,
|
|
24
|
+
EventType: () => EventType,
|
|
25
|
+
InMemoryStorageAdapter: () => InMemoryStorageAdapter,
|
|
26
|
+
VantageEngine: () => VantageEngine
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/events.ts
|
|
31
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
32
|
+
EventType2["OrchestrationStarted"] = "orchestration.started";
|
|
33
|
+
EventType2["TaskCreated"] = "task.created";
|
|
34
|
+
EventType2["TaskDependency"] = "task.dependency";
|
|
35
|
+
EventType2["SessionSpawned"] = "session.spawned";
|
|
36
|
+
EventType2["SessionEvent"] = "session.event";
|
|
37
|
+
EventType2["SessionSteered"] = "session.steered";
|
|
38
|
+
EventType2["SessionArtifact"] = "session.artifact";
|
|
39
|
+
EventType2["SessionCompleted"] = "session.completed";
|
|
40
|
+
EventType2["TaskCompleted"] = "task.completed";
|
|
41
|
+
EventType2["OrchestrationCompleted"] = "orchestration.completed";
|
|
42
|
+
EventType2["SubscriptionTriggered"] = "subscription.triggered";
|
|
43
|
+
return EventType2;
|
|
44
|
+
})(EventType || {});
|
|
45
|
+
|
|
46
|
+
// src/bus.ts
|
|
47
|
+
var EventBus = class {
|
|
48
|
+
handlers = /* @__PURE__ */ new Map();
|
|
49
|
+
nextId = 0;
|
|
50
|
+
subscribe(filter, handler) {
|
|
51
|
+
const id = String(this.nextId++);
|
|
52
|
+
this.handlers.set(id, { filter, handler });
|
|
53
|
+
return id;
|
|
54
|
+
}
|
|
55
|
+
unsubscribe(id) {
|
|
56
|
+
this.handlers.delete(id);
|
|
57
|
+
}
|
|
58
|
+
async emit(event) {
|
|
59
|
+
const promises = [];
|
|
60
|
+
for (const [, { filter, handler }] of this.handlers) {
|
|
61
|
+
if (this.matches(event, filter)) {
|
|
62
|
+
const result = handler(event);
|
|
63
|
+
if (result instanceof Promise) {
|
|
64
|
+
promises.push(result);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
await Promise.all(promises);
|
|
69
|
+
}
|
|
70
|
+
matches(event, filter) {
|
|
71
|
+
if (filter.type && event.type !== filter.type) return false;
|
|
72
|
+
if (filter.sessionId && event.sessionId !== filter.sessionId) return false;
|
|
73
|
+
if (filter.orchestrationId && event.orchestrationId !== filter.orchestrationId) return false;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/vantage.ts
|
|
79
|
+
var VantageEngine = class {
|
|
80
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
81
|
+
register(subscription) {
|
|
82
|
+
this.subscriptions.set(subscription.id, subscription);
|
|
83
|
+
}
|
|
84
|
+
remove(subscriptionId) {
|
|
85
|
+
this.subscriptions.delete(subscriptionId);
|
|
86
|
+
}
|
|
87
|
+
/** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */
|
|
88
|
+
evaluate(_event) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
getSubscription(id) {
|
|
92
|
+
return this.subscriptions.get(id);
|
|
93
|
+
}
|
|
94
|
+
listSubscriptions() {
|
|
95
|
+
return Array.from(this.subscriptions.values());
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// src/storage.ts
|
|
100
|
+
var InMemoryStorageAdapter = class {
|
|
101
|
+
store = /* @__PURE__ */ new Map();
|
|
102
|
+
async get(key) {
|
|
103
|
+
return this.store.get(key);
|
|
104
|
+
}
|
|
105
|
+
async put(key, value) {
|
|
106
|
+
this.store.set(key, value);
|
|
107
|
+
}
|
|
108
|
+
async query(_query) {
|
|
109
|
+
return Array.from(this.store.values());
|
|
110
|
+
}
|
|
111
|
+
async delete(key) {
|
|
112
|
+
return this.store.delete(key);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
EventBus,
|
|
118
|
+
EventType,
|
|
119
|
+
InMemoryStorageAdapter,
|
|
120
|
+
VantageEngine
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/events.ts","../src/bus.ts","../src/vantage.ts","../src/storage.ts"],"sourcesContent":["export { EventType } from \"./events.js\";\nexport type { YesodEvent } from \"./events.js\";\n\nexport { EventBus } from \"./bus.js\";\nexport type { EventHandler, EventFilter } from \"./bus.js\";\n\nexport { VantageEngine } from \"./vantage.js\";\nexport type {\n Subscription,\n SubscriptionCondition,\n NotificationEvent,\n} from \"./vantage.js\";\n\nexport { InMemoryStorageAdapter } from \"./storage.js\";\nexport type { StorageAdapter, StorageQuery } from \"./storage.js\";\n\nexport type {\n SessionState,\n SessionControl,\n CodingSession,\n} from \"./session.js\";\n\nexport type { Scheduler, ReadyStep } from \"./scheduler.js\";\n\nexport type { Router, RuntimeRecommendation } from \"./router.js\";\n\nexport type { Workflow, WorkflowStep, WorkflowState } from \"./workflow.js\";\n","export enum EventType {\n OrchestrationStarted = \"orchestration.started\",\n TaskCreated = \"task.created\",\n TaskDependency = \"task.dependency\",\n SessionSpawned = \"session.spawned\",\n SessionEvent = \"session.event\",\n SessionSteered = \"session.steered\",\n SessionArtifact = \"session.artifact\",\n SessionCompleted = \"session.completed\",\n TaskCompleted = \"task.completed\",\n OrchestrationCompleted = \"orchestration.completed\",\n SubscriptionTriggered = \"subscription.triggered\",\n}\n\nexport interface YesodEvent {\n id: string;\n type: EventType;\n timestamp: string;\n sessionId?: string;\n orchestrationId?: string;\n taskId?: string;\n payload: Record<string, unknown>;\n}\n","import type { YesodEvent, EventType } from \"./events.js\";\n\nexport type EventHandler = (event: YesodEvent) => void | Promise<void>;\n\nexport interface EventFilter {\n type?: EventType;\n sessionId?: string;\n orchestrationId?: string;\n}\n\nexport class EventBus {\n private handlers = new Map<string, { filter: EventFilter; handler: EventHandler }>();\n private nextId = 0;\n\n subscribe(filter: EventFilter, handler: EventHandler): string {\n const id = String(this.nextId++);\n this.handlers.set(id, { filter, handler });\n return id;\n }\n\n unsubscribe(id: string): void {\n this.handlers.delete(id);\n }\n\n async emit(event: YesodEvent): Promise<void> {\n const promises: Promise<void>[] = [];\n for (const [, { filter, handler }] of this.handlers) {\n if (this.matches(event, filter)) {\n const result = handler(event);\n if (result instanceof Promise) {\n promises.push(result);\n }\n }\n }\n await Promise.all(promises);\n }\n\n private matches(event: YesodEvent, filter: EventFilter): boolean {\n if (filter.type && event.type !== filter.type) return false;\n if (filter.sessionId && event.sessionId !== filter.sessionId) return false;\n if (filter.orchestrationId && event.orchestrationId !== filter.orchestrationId) return false;\n return true;\n }\n}\n","import type { YesodEvent, EventType } from \"./events.js\";\n\nexport interface SubscriptionCondition {\n sessionId?: string;\n eventType: EventType;\n filter?: Record<string, unknown>;\n}\n\nexport interface Subscription {\n id: string;\n orchestratorSession: string;\n conditions: SubscriptionCondition[];\n mode: \"any\" | \"all\";\n}\n\nexport interface NotificationEvent {\n type: \"subscription.triggered\";\n subscriptionId: string;\n matchedEvents: YesodEvent[];\n}\n\nexport class VantageEngine {\n private subscriptions = new Map<string, Subscription>();\n\n register(subscription: Subscription): void {\n this.subscriptions.set(subscription.id, subscription);\n }\n\n remove(subscriptionId: string): void {\n this.subscriptions.delete(subscriptionId);\n }\n\n /** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */\n evaluate(_event: YesodEvent): NotificationEvent[] {\n // Stub — will implement condition matching and barrier tracking\n return [];\n }\n\n getSubscription(id: string): Subscription | undefined {\n return this.subscriptions.get(id);\n }\n\n listSubscriptions(): Subscription[] {\n return Array.from(this.subscriptions.values());\n }\n}\n","export interface StorageQuery {\n type?: string;\n sessionId?: string;\n orchestrationId?: string;\n from?: string;\n to?: string;\n limit?: number;\n}\n\nexport interface StorageAdapter {\n get(key: string): Promise<unknown | undefined>;\n put(key: string, value: unknown): Promise<void>;\n query(query: StorageQuery): Promise<unknown[]>;\n delete(key: string): Promise<boolean>;\n}\n\nexport class InMemoryStorageAdapter implements StorageAdapter {\n private store = new Map<string, unknown>();\n\n async get(key: string): Promise<unknown | undefined> {\n return this.store.get(key);\n }\n\n async put(key: string, value: unknown): Promise<void> {\n this.store.set(key, value);\n }\n\n async query(_query: StorageQuery): Promise<unknown[]> {\n // Stub — returns all values; real implementation would filter\n return Array.from(this.store.values());\n }\n\n async delete(key: string): Promise<boolean> {\n return this.store.delete(key);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,kBAAe;AACf,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,mBAAgB;AAChB,EAAAA,WAAA,4BAAyB;AACzB,EAAAA,WAAA,2BAAwB;AAXd,SAAAA;AAAA,GAAA;;;ACUL,IAAM,WAAN,MAAe;AAAA,EACZ,WAAW,oBAAI,IAA4D;AAAA,EAC3E,SAAS;AAAA,EAEjB,UAAU,QAAqB,SAA+B;AAC5D,UAAM,KAAK,OAAO,KAAK,QAAQ;AAC/B,SAAK,SAAS,IAAI,IAAI,EAAE,QAAQ,QAAQ,CAAC;AACzC,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,IAAkB;AAC5B,SAAK,SAAS,OAAO,EAAE;AAAA,EACzB;AAAA,EAEA,MAAM,KAAK,OAAkC;AAC3C,UAAM,WAA4B,CAAC;AACnC,eAAW,CAAC,EAAE,EAAE,QAAQ,QAAQ,CAAC,KAAK,KAAK,UAAU;AACnD,UAAI,KAAK,QAAQ,OAAO,MAAM,GAAG;AAC/B,cAAM,SAAS,QAAQ,KAAK;AAC5B,YAAI,kBAAkB,SAAS;AAC7B,mBAAS,KAAK,MAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AACA,UAAM,QAAQ,IAAI,QAAQ;AAAA,EAC5B;AAAA,EAEQ,QAAQ,OAAmB,QAA8B;AAC/D,QAAI,OAAO,QAAQ,MAAM,SAAS,OAAO,KAAM,QAAO;AACtD,QAAI,OAAO,aAAa,MAAM,cAAc,OAAO,UAAW,QAAO;AACrE,QAAI,OAAO,mBAAmB,MAAM,oBAAoB,OAAO,gBAAiB,QAAO;AACvF,WAAO;AAAA,EACT;AACF;;;ACtBO,IAAM,gBAAN,MAAoB;AAAA,EACjB,gBAAgB,oBAAI,IAA0B;AAAA,EAEtD,SAAS,cAAkC;AACzC,SAAK,cAAc,IAAI,aAAa,IAAI,YAAY;AAAA,EACtD;AAAA,EAEA,OAAO,gBAA8B;AACnC,SAAK,cAAc,OAAO,cAAc;AAAA,EAC1C;AAAA;AAAA,EAGA,SAAS,QAAyC;AAEhD,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,gBAAgB,IAAsC;AACpD,WAAO,KAAK,cAAc,IAAI,EAAE;AAAA,EAClC;AAAA,EAEA,oBAAoC;AAClC,WAAO,MAAM,KAAK,KAAK,cAAc,OAAO,CAAC;AAAA,EAC/C;AACF;;;AC7BO,IAAM,yBAAN,MAAuD;AAAA,EACpD,QAAQ,oBAAI,IAAqB;AAAA,EAEzC,MAAM,IAAI,KAA2C;AACnD,WAAO,KAAK,MAAM,IAAI,GAAG;AAAA,EAC3B;AAAA,EAEA,MAAM,IAAI,KAAa,OAA+B;AACpD,SAAK,MAAM,IAAI,KAAK,KAAK;AAAA,EAC3B;AAAA,EAEA,MAAM,MAAM,QAA0C;AAEpD,WAAO,MAAM,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,EACvC;AAAA,EAEA,MAAM,OAAO,KAA+B;AAC1C,WAAO,KAAK,MAAM,OAAO,GAAG;AAAA,EAC9B;AACF;","names":["EventType"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
declare enum EventType {
|
|
2
|
+
OrchestrationStarted = "orchestration.started",
|
|
3
|
+
TaskCreated = "task.created",
|
|
4
|
+
TaskDependency = "task.dependency",
|
|
5
|
+
SessionSpawned = "session.spawned",
|
|
6
|
+
SessionEvent = "session.event",
|
|
7
|
+
SessionSteered = "session.steered",
|
|
8
|
+
SessionArtifact = "session.artifact",
|
|
9
|
+
SessionCompleted = "session.completed",
|
|
10
|
+
TaskCompleted = "task.completed",
|
|
11
|
+
OrchestrationCompleted = "orchestration.completed",
|
|
12
|
+
SubscriptionTriggered = "subscription.triggered"
|
|
13
|
+
}
|
|
14
|
+
interface YesodEvent {
|
|
15
|
+
id: string;
|
|
16
|
+
type: EventType;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
orchestrationId?: string;
|
|
20
|
+
taskId?: string;
|
|
21
|
+
payload: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type EventHandler = (event: YesodEvent) => void | Promise<void>;
|
|
25
|
+
interface EventFilter {
|
|
26
|
+
type?: EventType;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
orchestrationId?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class EventBus {
|
|
31
|
+
private handlers;
|
|
32
|
+
private nextId;
|
|
33
|
+
subscribe(filter: EventFilter, handler: EventHandler): string;
|
|
34
|
+
unsubscribe(id: string): void;
|
|
35
|
+
emit(event: YesodEvent): Promise<void>;
|
|
36
|
+
private matches;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SubscriptionCondition {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
eventType: EventType;
|
|
42
|
+
filter?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface Subscription {
|
|
45
|
+
id: string;
|
|
46
|
+
orchestratorSession: string;
|
|
47
|
+
conditions: SubscriptionCondition[];
|
|
48
|
+
mode: "any" | "all";
|
|
49
|
+
}
|
|
50
|
+
interface NotificationEvent {
|
|
51
|
+
type: "subscription.triggered";
|
|
52
|
+
subscriptionId: string;
|
|
53
|
+
matchedEvents: YesodEvent[];
|
|
54
|
+
}
|
|
55
|
+
declare class VantageEngine {
|
|
56
|
+
private subscriptions;
|
|
57
|
+
register(subscription: Subscription): void;
|
|
58
|
+
remove(subscriptionId: string): void;
|
|
59
|
+
/** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */
|
|
60
|
+
evaluate(_event: YesodEvent): NotificationEvent[];
|
|
61
|
+
getSubscription(id: string): Subscription | undefined;
|
|
62
|
+
listSubscriptions(): Subscription[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface StorageQuery {
|
|
66
|
+
type?: string;
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
orchestrationId?: string;
|
|
69
|
+
from?: string;
|
|
70
|
+
to?: string;
|
|
71
|
+
limit?: number;
|
|
72
|
+
}
|
|
73
|
+
interface StorageAdapter {
|
|
74
|
+
get(key: string): Promise<unknown | undefined>;
|
|
75
|
+
put(key: string, value: unknown): Promise<void>;
|
|
76
|
+
query(query: StorageQuery): Promise<unknown[]>;
|
|
77
|
+
delete(key: string): Promise<boolean>;
|
|
78
|
+
}
|
|
79
|
+
declare class InMemoryStorageAdapter implements StorageAdapter {
|
|
80
|
+
private store;
|
|
81
|
+
get(key: string): Promise<unknown | undefined>;
|
|
82
|
+
put(key: string, value: unknown): Promise<void>;
|
|
83
|
+
query(_query: StorageQuery): Promise<unknown[]>;
|
|
84
|
+
delete(key: string): Promise<boolean>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type SessionState = "pending" | "running" | "yielded" | "completed" | "failed" | "cancelled";
|
|
88
|
+
interface SessionControl {
|
|
89
|
+
maxTurns?: number;
|
|
90
|
+
maxCost?: number;
|
|
91
|
+
maxDuration?: number;
|
|
92
|
+
allowedTools?: string[];
|
|
93
|
+
deniedTools?: string[];
|
|
94
|
+
}
|
|
95
|
+
interface CodingSession {
|
|
96
|
+
id: string;
|
|
97
|
+
orchestrationId: string;
|
|
98
|
+
taskId: string;
|
|
99
|
+
parentSessionId?: string;
|
|
100
|
+
state: SessionState;
|
|
101
|
+
controls: SessionControl;
|
|
102
|
+
startedAt?: string;
|
|
103
|
+
completedAt?: string;
|
|
104
|
+
result?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type WorkflowState = "created" | "running" | "paused" | "completed" | "failed";
|
|
108
|
+
interface WorkflowStep {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
dependsOn: string[];
|
|
113
|
+
taskId?: string;
|
|
114
|
+
state: WorkflowState;
|
|
115
|
+
}
|
|
116
|
+
interface Workflow {
|
|
117
|
+
id: string;
|
|
118
|
+
orchestrationId: string;
|
|
119
|
+
name: string;
|
|
120
|
+
steps: WorkflowStep[];
|
|
121
|
+
state: WorkflowState;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
completedAt?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface ReadyStep {
|
|
127
|
+
step: WorkflowStep;
|
|
128
|
+
reason: string;
|
|
129
|
+
}
|
|
130
|
+
interface Scheduler {
|
|
131
|
+
/** Reports which steps have all dependencies satisfied and are ready to execute. The agent decides what to actually run. */
|
|
132
|
+
getReadySteps(workflowId: string): ReadyStep[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface RuntimeRecommendation {
|
|
136
|
+
runtimeId: string;
|
|
137
|
+
name: string;
|
|
138
|
+
score: number;
|
|
139
|
+
reason: string;
|
|
140
|
+
}
|
|
141
|
+
interface Router {
|
|
142
|
+
/** Recommends available runtimes for a given task. The agent decides which to use. */
|
|
143
|
+
recommend(taskType: string): RuntimeRecommendation[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { type CodingSession, EventBus, type EventFilter, type EventHandler, EventType, InMemoryStorageAdapter, type NotificationEvent, type ReadyStep, type Router, type RuntimeRecommendation, type Scheduler, type SessionControl, type SessionState, type StorageAdapter, type StorageQuery, type Subscription, type SubscriptionCondition, VantageEngine, type Workflow, type WorkflowState, type WorkflowStep, type YesodEvent };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
declare enum EventType {
|
|
2
|
+
OrchestrationStarted = "orchestration.started",
|
|
3
|
+
TaskCreated = "task.created",
|
|
4
|
+
TaskDependency = "task.dependency",
|
|
5
|
+
SessionSpawned = "session.spawned",
|
|
6
|
+
SessionEvent = "session.event",
|
|
7
|
+
SessionSteered = "session.steered",
|
|
8
|
+
SessionArtifact = "session.artifact",
|
|
9
|
+
SessionCompleted = "session.completed",
|
|
10
|
+
TaskCompleted = "task.completed",
|
|
11
|
+
OrchestrationCompleted = "orchestration.completed",
|
|
12
|
+
SubscriptionTriggered = "subscription.triggered"
|
|
13
|
+
}
|
|
14
|
+
interface YesodEvent {
|
|
15
|
+
id: string;
|
|
16
|
+
type: EventType;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
orchestrationId?: string;
|
|
20
|
+
taskId?: string;
|
|
21
|
+
payload: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type EventHandler = (event: YesodEvent) => void | Promise<void>;
|
|
25
|
+
interface EventFilter {
|
|
26
|
+
type?: EventType;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
orchestrationId?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class EventBus {
|
|
31
|
+
private handlers;
|
|
32
|
+
private nextId;
|
|
33
|
+
subscribe(filter: EventFilter, handler: EventHandler): string;
|
|
34
|
+
unsubscribe(id: string): void;
|
|
35
|
+
emit(event: YesodEvent): Promise<void>;
|
|
36
|
+
private matches;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface SubscriptionCondition {
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
eventType: EventType;
|
|
42
|
+
filter?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
interface Subscription {
|
|
45
|
+
id: string;
|
|
46
|
+
orchestratorSession: string;
|
|
47
|
+
conditions: SubscriptionCondition[];
|
|
48
|
+
mode: "any" | "all";
|
|
49
|
+
}
|
|
50
|
+
interface NotificationEvent {
|
|
51
|
+
type: "subscription.triggered";
|
|
52
|
+
subscriptionId: string;
|
|
53
|
+
matchedEvents: YesodEvent[];
|
|
54
|
+
}
|
|
55
|
+
declare class VantageEngine {
|
|
56
|
+
private subscriptions;
|
|
57
|
+
register(subscription: Subscription): void;
|
|
58
|
+
remove(subscriptionId: string): void;
|
|
59
|
+
/** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */
|
|
60
|
+
evaluate(_event: YesodEvent): NotificationEvent[];
|
|
61
|
+
getSubscription(id: string): Subscription | undefined;
|
|
62
|
+
listSubscriptions(): Subscription[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface StorageQuery {
|
|
66
|
+
type?: string;
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
orchestrationId?: string;
|
|
69
|
+
from?: string;
|
|
70
|
+
to?: string;
|
|
71
|
+
limit?: number;
|
|
72
|
+
}
|
|
73
|
+
interface StorageAdapter {
|
|
74
|
+
get(key: string): Promise<unknown | undefined>;
|
|
75
|
+
put(key: string, value: unknown): Promise<void>;
|
|
76
|
+
query(query: StorageQuery): Promise<unknown[]>;
|
|
77
|
+
delete(key: string): Promise<boolean>;
|
|
78
|
+
}
|
|
79
|
+
declare class InMemoryStorageAdapter implements StorageAdapter {
|
|
80
|
+
private store;
|
|
81
|
+
get(key: string): Promise<unknown | undefined>;
|
|
82
|
+
put(key: string, value: unknown): Promise<void>;
|
|
83
|
+
query(_query: StorageQuery): Promise<unknown[]>;
|
|
84
|
+
delete(key: string): Promise<boolean>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type SessionState = "pending" | "running" | "yielded" | "completed" | "failed" | "cancelled";
|
|
88
|
+
interface SessionControl {
|
|
89
|
+
maxTurns?: number;
|
|
90
|
+
maxCost?: number;
|
|
91
|
+
maxDuration?: number;
|
|
92
|
+
allowedTools?: string[];
|
|
93
|
+
deniedTools?: string[];
|
|
94
|
+
}
|
|
95
|
+
interface CodingSession {
|
|
96
|
+
id: string;
|
|
97
|
+
orchestrationId: string;
|
|
98
|
+
taskId: string;
|
|
99
|
+
parentSessionId?: string;
|
|
100
|
+
state: SessionState;
|
|
101
|
+
controls: SessionControl;
|
|
102
|
+
startedAt?: string;
|
|
103
|
+
completedAt?: string;
|
|
104
|
+
result?: Record<string, unknown>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type WorkflowState = "created" | "running" | "paused" | "completed" | "failed";
|
|
108
|
+
interface WorkflowStep {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
dependsOn: string[];
|
|
113
|
+
taskId?: string;
|
|
114
|
+
state: WorkflowState;
|
|
115
|
+
}
|
|
116
|
+
interface Workflow {
|
|
117
|
+
id: string;
|
|
118
|
+
orchestrationId: string;
|
|
119
|
+
name: string;
|
|
120
|
+
steps: WorkflowStep[];
|
|
121
|
+
state: WorkflowState;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
completedAt?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface ReadyStep {
|
|
127
|
+
step: WorkflowStep;
|
|
128
|
+
reason: string;
|
|
129
|
+
}
|
|
130
|
+
interface Scheduler {
|
|
131
|
+
/** Reports which steps have all dependencies satisfied and are ready to execute. The agent decides what to actually run. */
|
|
132
|
+
getReadySteps(workflowId: string): ReadyStep[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface RuntimeRecommendation {
|
|
136
|
+
runtimeId: string;
|
|
137
|
+
name: string;
|
|
138
|
+
score: number;
|
|
139
|
+
reason: string;
|
|
140
|
+
}
|
|
141
|
+
interface Router {
|
|
142
|
+
/** Recommends available runtimes for a given task. The agent decides which to use. */
|
|
143
|
+
recommend(taskType: string): RuntimeRecommendation[];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { type CodingSession, EventBus, type EventFilter, type EventHandler, EventType, InMemoryStorageAdapter, type NotificationEvent, type ReadyStep, type Router, type RuntimeRecommendation, type Scheduler, type SessionControl, type SessionState, type StorageAdapter, type StorageQuery, type Subscription, type SubscriptionCondition, VantageEngine, type Workflow, type WorkflowState, type WorkflowStep, type YesodEvent };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/events.ts
|
|
2
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
3
|
+
EventType2["OrchestrationStarted"] = "orchestration.started";
|
|
4
|
+
EventType2["TaskCreated"] = "task.created";
|
|
5
|
+
EventType2["TaskDependency"] = "task.dependency";
|
|
6
|
+
EventType2["SessionSpawned"] = "session.spawned";
|
|
7
|
+
EventType2["SessionEvent"] = "session.event";
|
|
8
|
+
EventType2["SessionSteered"] = "session.steered";
|
|
9
|
+
EventType2["SessionArtifact"] = "session.artifact";
|
|
10
|
+
EventType2["SessionCompleted"] = "session.completed";
|
|
11
|
+
EventType2["TaskCompleted"] = "task.completed";
|
|
12
|
+
EventType2["OrchestrationCompleted"] = "orchestration.completed";
|
|
13
|
+
EventType2["SubscriptionTriggered"] = "subscription.triggered";
|
|
14
|
+
return EventType2;
|
|
15
|
+
})(EventType || {});
|
|
16
|
+
|
|
17
|
+
// src/bus.ts
|
|
18
|
+
var EventBus = class {
|
|
19
|
+
handlers = /* @__PURE__ */ new Map();
|
|
20
|
+
nextId = 0;
|
|
21
|
+
subscribe(filter, handler) {
|
|
22
|
+
const id = String(this.nextId++);
|
|
23
|
+
this.handlers.set(id, { filter, handler });
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
unsubscribe(id) {
|
|
27
|
+
this.handlers.delete(id);
|
|
28
|
+
}
|
|
29
|
+
async emit(event) {
|
|
30
|
+
const promises = [];
|
|
31
|
+
for (const [, { filter, handler }] of this.handlers) {
|
|
32
|
+
if (this.matches(event, filter)) {
|
|
33
|
+
const result = handler(event);
|
|
34
|
+
if (result instanceof Promise) {
|
|
35
|
+
promises.push(result);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
await Promise.all(promises);
|
|
40
|
+
}
|
|
41
|
+
matches(event, filter) {
|
|
42
|
+
if (filter.type && event.type !== filter.type) return false;
|
|
43
|
+
if (filter.sessionId && event.sessionId !== filter.sessionId) return false;
|
|
44
|
+
if (filter.orchestrationId && event.orchestrationId !== filter.orchestrationId) return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/vantage.ts
|
|
50
|
+
var VantageEngine = class {
|
|
51
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
52
|
+
register(subscription) {
|
|
53
|
+
this.subscriptions.set(subscription.id, subscription);
|
|
54
|
+
}
|
|
55
|
+
remove(subscriptionId) {
|
|
56
|
+
this.subscriptions.delete(subscriptionId);
|
|
57
|
+
}
|
|
58
|
+
/** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */
|
|
59
|
+
evaluate(_event) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
getSubscription(id) {
|
|
63
|
+
return this.subscriptions.get(id);
|
|
64
|
+
}
|
|
65
|
+
listSubscriptions() {
|
|
66
|
+
return Array.from(this.subscriptions.values());
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/storage.ts
|
|
71
|
+
var InMemoryStorageAdapter = class {
|
|
72
|
+
store = /* @__PURE__ */ new Map();
|
|
73
|
+
async get(key) {
|
|
74
|
+
return this.store.get(key);
|
|
75
|
+
}
|
|
76
|
+
async put(key, value) {
|
|
77
|
+
this.store.set(key, value);
|
|
78
|
+
}
|
|
79
|
+
async query(_query) {
|
|
80
|
+
return Array.from(this.store.values());
|
|
81
|
+
}
|
|
82
|
+
async delete(key) {
|
|
83
|
+
return this.store.delete(key);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
EventBus,
|
|
88
|
+
EventType,
|
|
89
|
+
InMemoryStorageAdapter,
|
|
90
|
+
VantageEngine
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/events.ts","../src/bus.ts","../src/vantage.ts","../src/storage.ts"],"sourcesContent":["export enum EventType {\n OrchestrationStarted = \"orchestration.started\",\n TaskCreated = \"task.created\",\n TaskDependency = \"task.dependency\",\n SessionSpawned = \"session.spawned\",\n SessionEvent = \"session.event\",\n SessionSteered = \"session.steered\",\n SessionArtifact = \"session.artifact\",\n SessionCompleted = \"session.completed\",\n TaskCompleted = \"task.completed\",\n OrchestrationCompleted = \"orchestration.completed\",\n SubscriptionTriggered = \"subscription.triggered\",\n}\n\nexport interface YesodEvent {\n id: string;\n type: EventType;\n timestamp: string;\n sessionId?: string;\n orchestrationId?: string;\n taskId?: string;\n payload: Record<string, unknown>;\n}\n","import type { YesodEvent, EventType } from \"./events.js\";\n\nexport type EventHandler = (event: YesodEvent) => void | Promise<void>;\n\nexport interface EventFilter {\n type?: EventType;\n sessionId?: string;\n orchestrationId?: string;\n}\n\nexport class EventBus {\n private handlers = new Map<string, { filter: EventFilter; handler: EventHandler }>();\n private nextId = 0;\n\n subscribe(filter: EventFilter, handler: EventHandler): string {\n const id = String(this.nextId++);\n this.handlers.set(id, { filter, handler });\n return id;\n }\n\n unsubscribe(id: string): void {\n this.handlers.delete(id);\n }\n\n async emit(event: YesodEvent): Promise<void> {\n const promises: Promise<void>[] = [];\n for (const [, { filter, handler }] of this.handlers) {\n if (this.matches(event, filter)) {\n const result = handler(event);\n if (result instanceof Promise) {\n promises.push(result);\n }\n }\n }\n await Promise.all(promises);\n }\n\n private matches(event: YesodEvent, filter: EventFilter): boolean {\n if (filter.type && event.type !== filter.type) return false;\n if (filter.sessionId && event.sessionId !== filter.sessionId) return false;\n if (filter.orchestrationId && event.orchestrationId !== filter.orchestrationId) return false;\n return true;\n }\n}\n","import type { YesodEvent, EventType } from \"./events.js\";\n\nexport interface SubscriptionCondition {\n sessionId?: string;\n eventType: EventType;\n filter?: Record<string, unknown>;\n}\n\nexport interface Subscription {\n id: string;\n orchestratorSession: string;\n conditions: SubscriptionCondition[];\n mode: \"any\" | \"all\";\n}\n\nexport interface NotificationEvent {\n type: \"subscription.triggered\";\n subscriptionId: string;\n matchedEvents: YesodEvent[];\n}\n\nexport class VantageEngine {\n private subscriptions = new Map<string, Subscription>();\n\n register(subscription: Subscription): void {\n this.subscriptions.set(subscription.id, subscription);\n }\n\n remove(subscriptionId: string): void {\n this.subscriptions.delete(subscriptionId);\n }\n\n /** Evaluate an incoming event against all subscriptions. Returns notifications for any triggered subscriptions. */\n evaluate(_event: YesodEvent): NotificationEvent[] {\n // Stub — will implement condition matching and barrier tracking\n return [];\n }\n\n getSubscription(id: string): Subscription | undefined {\n return this.subscriptions.get(id);\n }\n\n listSubscriptions(): Subscription[] {\n return Array.from(this.subscriptions.values());\n }\n}\n","export interface StorageQuery {\n type?: string;\n sessionId?: string;\n orchestrationId?: string;\n from?: string;\n to?: string;\n limit?: number;\n}\n\nexport interface StorageAdapter {\n get(key: string): Promise<unknown | undefined>;\n put(key: string, value: unknown): Promise<void>;\n query(query: StorageQuery): Promise<unknown[]>;\n delete(key: string): Promise<boolean>;\n}\n\nexport class InMemoryStorageAdapter implements StorageAdapter {\n private store = new Map<string, unknown>();\n\n async get(key: string): Promise<unknown | undefined> {\n return this.store.get(key);\n }\n\n async put(key: string, value: unknown): Promise<void> {\n this.store.set(key, value);\n }\n\n async query(_query: StorageQuery): Promise<unknown[]> {\n // Stub — returns all values; real implementation would filter\n return Array.from(this.store.values());\n }\n\n async delete(key: string): Promise<boolean> {\n return this.store.delete(key);\n }\n}\n"],"mappings":";AAAO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,0BAAuB;AACvB,EAAAA,WAAA,iBAAc;AACd,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,kBAAe;AACf,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,qBAAkB;AAClB,EAAAA,WAAA,sBAAmB;AACnB,EAAAA,WAAA,mBAAgB;AAChB,EAAAA,WAAA,4BAAyB;AACzB,EAAAA,WAAA,2BAAwB;AAXd,SAAAA;AAAA,GAAA;;;ACUL,IAAM,WAAN,MAAe;AAAA,EACZ,WAAW,oBAAI,IAA4D;AAAA,EAC3E,SAAS;AAAA,EAEjB,UAAU,QAAqB,SAA+B;AAC5D,UAAM,KAAK,OAAO,KAAK,QAAQ;AAC/B,SAAK,SAAS,IAAI,IAAI,EAAE,QAAQ,QAAQ,CAAC;AACzC,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,IAAkB;AAC5B,SAAK,SAAS,OAAO,EAAE;AAAA,EACzB;AAAA,EAEA,MAAM,KAAK,OAAkC;AAC3C,UAAM,WAA4B,CAAC;AACnC,eAAW,CAAC,EAAE,EAAE,QAAQ,QAAQ,CAAC,KAAK,KAAK,UAAU;AACnD,UAAI,KAAK,QAAQ,OAAO,MAAM,GAAG;AAC/B,cAAM,SAAS,QAAQ,KAAK;AAC5B,YAAI,kBAAkB,SAAS;AAC7B,mBAAS,KAAK,MAAM;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AACA,UAAM,QAAQ,IAAI,QAAQ;AAAA,EAC5B;AAAA,EAEQ,QAAQ,OAAmB,QAA8B;AAC/D,QAAI,OAAO,QAAQ,MAAM,SAAS,OAAO,KAAM,QAAO;AACtD,QAAI,OAAO,aAAa,MAAM,cAAc,OAAO,UAAW,QAAO;AACrE,QAAI,OAAO,mBAAmB,MAAM,oBAAoB,OAAO,gBAAiB,QAAO;AACvF,WAAO;AAAA,EACT;AACF;;;ACtBO,IAAM,gBAAN,MAAoB;AAAA,EACjB,gBAAgB,oBAAI,IAA0B;AAAA,EAEtD,SAAS,cAAkC;AACzC,SAAK,cAAc,IAAI,aAAa,IAAI,YAAY;AAAA,EACtD;AAAA,EAEA,OAAO,gBAA8B;AACnC,SAAK,cAAc,OAAO,cAAc;AAAA,EAC1C;AAAA;AAAA,EAGA,SAAS,QAAyC;AAEhD,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,gBAAgB,IAAsC;AACpD,WAAO,KAAK,cAAc,IAAI,EAAE;AAAA,EAClC;AAAA,EAEA,oBAAoC;AAClC,WAAO,MAAM,KAAK,KAAK,cAAc,OAAO,CAAC;AAAA,EAC/C;AACF;;;AC7BO,IAAM,yBAAN,MAAuD;AAAA,EACpD,QAAQ,oBAAI,IAAqB;AAAA,EAEzC,MAAM,IAAI,KAA2C;AACnD,WAAO,KAAK,MAAM,IAAI,GAAG;AAAA,EAC3B;AAAA,EAEA,MAAM,IAAI,KAAa,OAA+B;AACpD,SAAK,MAAM,IAAI,KAAK,KAAK;AAAA,EAC3B;AAAA,EAEA,MAAM,MAAM,QAA0C;AAEpD,WAAO,MAAM,KAAK,KAAK,MAAM,OAAO,CAAC;AAAA,EACvC;AAAA,EAEA,MAAM,OAAO,KAA+B;AAC1C,WAAO,KAAK,MAAM,OAAO,GAAG;AAAA,EAC9B;AACF;","names":["EventType"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yesod/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/eryv-ai/yesod.git",
|
|
7
|
+
"directory": "packages/core"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.cjs",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"files": ["dist"],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"clean": "rm -rf dist"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.4.0",
|
|
31
|
+
"typescript": "^5.8.0",
|
|
32
|
+
"vitest": "^3.1.0"
|
|
33
|
+
}
|
|
34
|
+
}
|