@theaiinc/yggdrasil 0.2.1 → 0.3.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/README.md +157 -0
- package/dist/src/index.d.ts +6 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/orchestration-controller.d.ts +13 -1
- package/dist/src/orchestration-controller.d.ts.map +1 -1
- package/dist/src/orchestration-controller.js +419 -50
- package/dist/src/orchestration-controller.js.map +1 -1
- package/dist/src/services/realm-lifecycle.d.ts +49 -0
- package/dist/src/services/realm-lifecycle.d.ts.map +1 -0
- package/dist/src/services/realm-lifecycle.js +154 -0
- package/dist/src/services/realm-lifecycle.js.map +1 -0
- package/dist/src/services/realm-provisioner.d.ts +45 -0
- package/dist/src/services/realm-provisioner.d.ts.map +1 -0
- package/dist/src/services/realm-provisioner.js +102 -0
- package/dist/src/services/realm-provisioner.js.map +1 -0
- package/dist/src/services/realm-registry.d.ts +83 -0
- package/dist/src/services/realm-registry.d.ts.map +1 -0
- package/dist/src/services/realm-registry.js +136 -0
- package/dist/src/services/realm-registry.js.map +1 -0
- package/dist/src/services/realm-scheduler.d.ts +47 -0
- package/dist/src/services/realm-scheduler.d.ts.map +1 -0
- package/dist/src/services/realm-scheduler.js +112 -0
- package/dist/src/services/realm-scheduler.js.map +1 -0
- package/dist/src/types/index.d.ts +270 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +6 -1
- package/dist/src/types/index.js.map +1 -1
- package/package.json +25 -5
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RealmScheduler — makes allocation decisions for session requests.
|
|
3
|
+
*
|
|
4
|
+
* Yggdrasil owns all scheduling policy:
|
|
5
|
+
* - Which realm type?
|
|
6
|
+
* - Which owner?
|
|
7
|
+
* - Reuse allowed?
|
|
8
|
+
* - Spawn allowed?
|
|
9
|
+
* - Priority?
|
|
10
|
+
*
|
|
11
|
+
* Ratatoskr reports facts (CPU, memory, realms, templates).
|
|
12
|
+
* Yggdrasil decides. Ratatoskr may veto ("I cannot do that") but
|
|
13
|
+
* must never suggest alternatives — that is orchestration.
|
|
14
|
+
*
|
|
15
|
+
* Current implementation:
|
|
16
|
+
* Simple first-fit by template match + online status.
|
|
17
|
+
*
|
|
18
|
+
* Future:
|
|
19
|
+
* Resource-aware, owner-aware, cost-aware, affinity-aware,
|
|
20
|
+
* informed by Ratatoskr's /state endpoint.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Map from SessionType to the required RealmTemplateType.
|
|
24
|
+
*/
|
|
25
|
+
const SESSION_TO_TEMPLATE = {
|
|
26
|
+
'computer-use': 'ubuntu',
|
|
27
|
+
'phone-use': 'android',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Default capabilities for a template when none are explicitly advertised.
|
|
31
|
+
*/
|
|
32
|
+
const DEFAULT_TEMPLATE_CAPABILITIES = {
|
|
33
|
+
ubuntu: ['observe', 'mouse', 'keyboard', 'scroll', 'clipboard'],
|
|
34
|
+
android: ['observe', 'touch', 'keyboard', 'scroll'],
|
|
35
|
+
browser: ['observe', 'keyboard'],
|
|
36
|
+
windows: ['observe', 'mouse', 'keyboard', 'scroll'],
|
|
37
|
+
};
|
|
38
|
+
export class RealmScheduler {
|
|
39
|
+
registry;
|
|
40
|
+
getRunner;
|
|
41
|
+
constructor(registry, getRunner) {
|
|
42
|
+
this.registry = registry;
|
|
43
|
+
this.getRunner = getRunner;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Decide how to allocate a realm for a session request.
|
|
47
|
+
*
|
|
48
|
+
* Yggdrasil decides:
|
|
49
|
+
* - Which runner
|
|
50
|
+
* - Which template
|
|
51
|
+
* - Whether to spawn new or attach to existing
|
|
52
|
+
*
|
|
53
|
+
* Priority order:
|
|
54
|
+
* 1. Attach to existing realm owned by this owner (persistent realm)
|
|
55
|
+
* 2. Attach to a pooled idle realm (pre-warmed)
|
|
56
|
+
* 3. Spawn a new realm on a healthy runner
|
|
57
|
+
*/
|
|
58
|
+
async schedule(request) {
|
|
59
|
+
const templateType = SESSION_TO_TEMPLATE[request.type];
|
|
60
|
+
if (!templateType) {
|
|
61
|
+
throw new Error(`No realm template available for session type: ${request.type}`);
|
|
62
|
+
}
|
|
63
|
+
// Priority 1: Persistent realm affinity by owner
|
|
64
|
+
if (request.ownerId) {
|
|
65
|
+
const existing = this.registry.findRealmByOwner(request.ownerId, templateType);
|
|
66
|
+
if (existing) {
|
|
67
|
+
const entry = this.registry.getEntry(existing.id);
|
|
68
|
+
return {
|
|
69
|
+
runnerId: existing.runnerId,
|
|
70
|
+
template: entry.template,
|
|
71
|
+
action: 'attach',
|
|
72
|
+
realmId: existing.id,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Priority 2: Pooled idle realm
|
|
77
|
+
const pooled = this.registry.findPooledRealm(templateType);
|
|
78
|
+
if (pooled) {
|
|
79
|
+
const entry = this.registry.getEntry(pooled.id);
|
|
80
|
+
return {
|
|
81
|
+
runnerId: pooled.runnerId,
|
|
82
|
+
template: entry.template,
|
|
83
|
+
action: 'attach',
|
|
84
|
+
realmId: pooled.id,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Priority 3: Find a runner that can host this template type
|
|
88
|
+
const candidates = this.registry.getTemplatesByType(templateType);
|
|
89
|
+
if (candidates.length === 0) {
|
|
90
|
+
throw new Error(`No runner available that can host realm type: ${templateType}`);
|
|
91
|
+
}
|
|
92
|
+
// Pick first healthy runner with capacity
|
|
93
|
+
for (const candidate of candidates) {
|
|
94
|
+
const runner = this.getRunner(candidate.runnerId);
|
|
95
|
+
if (runner && runner.status === 'online') {
|
|
96
|
+
return {
|
|
97
|
+
runnerId: candidate.runnerId,
|
|
98
|
+
template: candidate.template,
|
|
99
|
+
action: 'spawn',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`No online runner available for realm type: ${templateType}`);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Resolve default capabilities for a template type when not explicitly provided.
|
|
107
|
+
*/
|
|
108
|
+
static defaultCapabilitiesFor(type) {
|
|
109
|
+
return DEFAULT_TEMPLATE_CAPABILITIES[type] ?? ['observe'];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=realm-scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realm-scheduler.js","sourceRoot":"","sources":["../../../src/services/realm-scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH;;GAEG;AACH,MAAM,mBAAmB,GAA2B;IAClD,cAAc,EAAE,QAAQ;IACxB,WAAW,EAAE,SAAS;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,6BAA6B,GAAwC;IACzE,MAAM,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC;IAC/D,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;IACnD,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IAChC,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;CACpD,CAAC;AAEF,MAAM,OAAO,cAAc;IAEN;IACA;IAFnB,YACmB,QAAuB,EACvB,SAAuD;QADvD,aAAQ,GAAR,QAAQ,CAAe;QACvB,cAAS,GAAT,SAAS,CAA8C;IACvE,CAAC;IAEJ;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,QAAQ,CAAC,OAA6B;QAC1C,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,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E,CAAC;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAClD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACzC,OAAO;oBACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;oBAC5B,QAAQ,EAAE,SAAS,CAAC,QAAQ;oBAC5B,MAAM,EAAE,OAAO;iBAChB,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,8CAA8C,YAAY,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,sBAAsB,CAAC,IAAY;QACxC,OAAO,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Runtime types for the Yggdrasil orchestration system.
|
|
3
|
+
*
|
|
4
|
+
* These types define the wire protocol between Yggdrasil (the controller)
|
|
5
|
+
* and Ratatoskr (the runner daemon). They are consumed by both the
|
|
6
|
+
* controller itself and by custom pools (like Oasis yggdrasil-pool.ts)
|
|
7
|
+
* that embed the controller API.
|
|
3
8
|
*/
|
|
4
9
|
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
5
10
|
export interface LoggerConfig {
|
|
@@ -7,4 +12,268 @@ export interface LoggerConfig {
|
|
|
7
12
|
format: 'json' | 'simple';
|
|
8
13
|
transports: string[];
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Registration payload sent by a Realm instance (via Ratatoskr) to Yggdrasil.
|
|
17
|
+
* Realm announces itself after boot.
|
|
18
|
+
*/
|
|
19
|
+
export interface RealmRegistration {
|
|
20
|
+
realmId: string;
|
|
21
|
+
runnerId: string;
|
|
22
|
+
/** The template type this realm was spawned from (e.g. "ubuntu", "android"). */
|
|
23
|
+
template: RealmTemplateType;
|
|
24
|
+
/** Realm software version. */
|
|
25
|
+
version: string;
|
|
26
|
+
/** Capabilities this realm instance provides. */
|
|
27
|
+
capabilities: SessionCapability[];
|
|
28
|
+
/** Live endpoints for observation and input. */
|
|
29
|
+
endpoints: {
|
|
30
|
+
observation: string;
|
|
31
|
+
input: string;
|
|
32
|
+
};
|
|
33
|
+
/** Future: Veil-issued token for authenticating registrations. */
|
|
34
|
+
registrationToken?: string | undefined;
|
|
35
|
+
startedAt: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Periodic heartbeat from a Realm instance (via Ratatoskr) to Yggdrasil.
|
|
39
|
+
*/
|
|
40
|
+
export interface RealmHeartbeat {
|
|
41
|
+
realmId: string;
|
|
42
|
+
uptime: number;
|
|
43
|
+
healthy: boolean;
|
|
44
|
+
memoryMb?: number | undefined;
|
|
45
|
+
cpuPercent?: number | undefined;
|
|
46
|
+
activeSessions: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Deregistration payload sent by a Realm instance on shutdown.
|
|
50
|
+
*/
|
|
51
|
+
export interface RealmDeregistration {
|
|
52
|
+
realmId: string;
|
|
53
|
+
reason: 'shutdown' | 'error' | 'replaced';
|
|
54
|
+
}
|
|
55
|
+
/** Supported session types for interaction with execution environments. */
|
|
56
|
+
export type SessionType = 'computer-use' | 'phone-use';
|
|
57
|
+
/** Lifecycle states for a session. */
|
|
58
|
+
export type SessionState = 'creating' | 'active' | 'paused' | 'completed' | 'failed' | 'terminated';
|
|
59
|
+
/** Observation method chosen by Realm — consumers must not depend on a specific implementation. */
|
|
60
|
+
export type ObservationMethod = 'accessibility_tree' | 'dom_snapshot' | 'screenshot' | 'video_stream' | 'hybrid';
|
|
61
|
+
/** Input capabilities a session may expose. */
|
|
62
|
+
export type InputCapability = 'mouse' | 'keyboard' | 'touch' | 'scroll' | 'drag' | 'clipboard';
|
|
63
|
+
/**
|
|
64
|
+
* Capabilities a session may support — used for session contracts and Veil authorization.
|
|
65
|
+
* Broader than InputCapability: includes observation and device-level capabilities.
|
|
66
|
+
*/
|
|
67
|
+
export type SessionCapability = 'observe' | 'mouse' | 'keyboard' | 'touch' | 'scroll' | 'drag' | 'clipboard' | 'audio' | 'camera';
|
|
68
|
+
/** Types of execution environments a runner can host. */
|
|
69
|
+
export type RealmTemplateType = 'ubuntu' | 'android' | 'browser' | 'windows';
|
|
70
|
+
/** Lifecycle states for a Realm instance. */
|
|
71
|
+
export type RealmState = 'creating' | 'running' | 'paused' | 'unhealthy' | 'destroyed';
|
|
72
|
+
/**
|
|
73
|
+
* A realm template advertised by a runner via Ratatoskr.
|
|
74
|
+
* Templates describe what kinds of environments a runner CAN spawn,
|
|
75
|
+
* not what is currently running.
|
|
76
|
+
*/
|
|
77
|
+
export interface RealmTemplate {
|
|
78
|
+
id: string;
|
|
79
|
+
type: RealmTemplateType;
|
|
80
|
+
/** Capabilities this template provides when a realm is spawned (e.g. ["observe", "mouse", "keyboard"]). */
|
|
81
|
+
capabilities: SessionCapability[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A running Realm instance — the actual execution environment that sessions attach to.
|
|
85
|
+
*
|
|
86
|
+
* Sessions do NOT run on runners. Sessions run on realms. Realms run on runners.
|
|
87
|
+
*/
|
|
88
|
+
export interface Realm {
|
|
89
|
+
id: string;
|
|
90
|
+
templateId: string;
|
|
91
|
+
runnerId: string;
|
|
92
|
+
/** The entity that owns or requested this realm (used for persistent realm affinity). */
|
|
93
|
+
ownerId?: string | undefined;
|
|
94
|
+
state: RealmState;
|
|
95
|
+
endpoints: {
|
|
96
|
+
/** Full URL for observation (e.g. screenshots, a11y tree). */
|
|
97
|
+
observation: string;
|
|
98
|
+
/** Full URL for input (e.g. click, type, scroll). */
|
|
99
|
+
input: string;
|
|
100
|
+
};
|
|
101
|
+
createdAt: string;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
/** Timestamp of the last heartbeat received from this realm. */
|
|
104
|
+
lastHeartbeat?: string | undefined;
|
|
105
|
+
/** Future: Veil-issued token for authenticating realm operations. */
|
|
106
|
+
registrationToken?: string | undefined;
|
|
107
|
+
/** Pool tag — if set, this realm can be reused for sessions matching the same template+owner. */
|
|
108
|
+
poolTag?: string | undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Result of a scheduling decision. The scheduler returns an allocation;
|
|
112
|
+
* the provisioner acts on it.
|
|
113
|
+
*/
|
|
114
|
+
export interface RealmAllocation {
|
|
115
|
+
runnerId: string;
|
|
116
|
+
template: RealmTemplate;
|
|
117
|
+
/** Whether to spawn a new realm or attach to an existing one. */
|
|
118
|
+
action: 'spawn' | 'attach';
|
|
119
|
+
/** Set when attaching to an existing realm. */
|
|
120
|
+
realmId?: string | undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Descriptor for an active session.
|
|
124
|
+
*
|
|
125
|
+
* Yggdrasil is the **control plane** — it creates/terminates/pauses/resumes sessions.
|
|
126
|
+
* Realm is the **data plane** — observation and input go DIRECTLY to Realm endpoints,
|
|
127
|
+
* NOT through Yggdrasil.
|
|
128
|
+
*
|
|
129
|
+
* Consumers (Cognition via ComputerUseRuntime) use observationEndpoint and
|
|
130
|
+
* inputEndpoint to talk to Realm directly. Yggdrasil never proxies observe/input calls.
|
|
131
|
+
*/
|
|
132
|
+
export interface SessionDescriptor {
|
|
133
|
+
id: string;
|
|
134
|
+
type: SessionType;
|
|
135
|
+
state: SessionState;
|
|
136
|
+
/** Full Realm URL for observation (e.g. screenshots, a11y tree, DOM). Consumers talk to Realm directly. */
|
|
137
|
+
observationEndpoint: string;
|
|
138
|
+
/** Full Realm URL for input (e.g. click, type, scroll). Consumers talk to Realm directly. */
|
|
139
|
+
inputEndpoint: string;
|
|
140
|
+
/** Capabilities this session supports (e.g. ["mouse", "keyboard"]). */
|
|
141
|
+
capabilities: SessionCapability[];
|
|
142
|
+
/** The observation method Realm chose (internal detail — informational only). */
|
|
143
|
+
observationMethod: ObservationMethod;
|
|
144
|
+
/** Realm ID backing this session. */
|
|
145
|
+
realmId: string;
|
|
146
|
+
/** Identity of the entity that owns this session. */
|
|
147
|
+
ownerId?: string | undefined;
|
|
148
|
+
/** Identities of participants allowed to interact with this session. */
|
|
149
|
+
participantIds?: string[] | undefined;
|
|
150
|
+
createdAt: string;
|
|
151
|
+
updatedAt: string;
|
|
152
|
+
metadata?: Record<string, unknown> | undefined;
|
|
153
|
+
}
|
|
154
|
+
/** Request to create a new interaction session. */
|
|
155
|
+
export interface CreateSessionRequest {
|
|
156
|
+
type: SessionType;
|
|
157
|
+
ownerId?: string | undefined;
|
|
158
|
+
participantIds?: string[] | undefined;
|
|
159
|
+
/** Requested capabilities for this session. If omitted, type defaults apply. */
|
|
160
|
+
capabilities?: SessionCapability[] | undefined;
|
|
161
|
+
realmId?: string | undefined;
|
|
162
|
+
metadata?: Record<string, unknown> | undefined;
|
|
163
|
+
}
|
|
164
|
+
/** Response from creating a session. */
|
|
165
|
+
export interface CreateSessionResponse {
|
|
166
|
+
sessionId: string;
|
|
167
|
+
descriptor: SessionDescriptor;
|
|
168
|
+
}
|
|
169
|
+
/** Observation payload returned by a session's observe endpoint. */
|
|
170
|
+
export interface SessionObservation {
|
|
171
|
+
/** Base64-encoded screenshot (when method is screenshot or hybrid). */
|
|
172
|
+
screenshot?: string | undefined;
|
|
173
|
+
/** Accessibility tree snapshot (when method is accessibility_tree or hybrid). */
|
|
174
|
+
accessibilityTree?: unknown;
|
|
175
|
+
/** DOM snapshot (when method is dom_snapshot or hybrid). */
|
|
176
|
+
domSnapshot?: unknown;
|
|
177
|
+
/** Whether PII redaction was applied. */
|
|
178
|
+
piiRedacted?: boolean | undefined;
|
|
179
|
+
/** Timestamp of the observation. */
|
|
180
|
+
timestamp: string;
|
|
181
|
+
/** Structured data for JSON-based observation (e.g. UI element tree). */
|
|
182
|
+
data?: Record<string, unknown> | undefined;
|
|
183
|
+
}
|
|
184
|
+
/** Input action sent to a session. */
|
|
185
|
+
export interface SessionInput {
|
|
186
|
+
type: InputCapability;
|
|
187
|
+
params: Record<string, unknown>;
|
|
188
|
+
}
|
|
189
|
+
/** Result of an input action. */
|
|
190
|
+
export interface SessionInputResult {
|
|
191
|
+
success: boolean;
|
|
192
|
+
error?: string | undefined;
|
|
193
|
+
}
|
|
194
|
+
/** Session health reported by Ratatoskr to Yggdrasil. */
|
|
195
|
+
export interface SessionHealth {
|
|
196
|
+
sessionId: string;
|
|
197
|
+
state: SessionState;
|
|
198
|
+
realmId: string;
|
|
199
|
+
lastObservationAt?: string | undefined;
|
|
200
|
+
lastInputAt?: string | undefined;
|
|
201
|
+
errorCount: number;
|
|
202
|
+
}
|
|
203
|
+
export interface SystemResources {
|
|
204
|
+
cpu: {
|
|
205
|
+
load1: number;
|
|
206
|
+
load5: number;
|
|
207
|
+
load15: number;
|
|
208
|
+
cpus: number;
|
|
209
|
+
percent: number;
|
|
210
|
+
};
|
|
211
|
+
memory: {
|
|
212
|
+
total: number;
|
|
213
|
+
used: number;
|
|
214
|
+
free: number;
|
|
215
|
+
percent: number;
|
|
216
|
+
};
|
|
217
|
+
uptime: number;
|
|
218
|
+
}
|
|
219
|
+
export interface PendingUpdate {
|
|
220
|
+
version: string;
|
|
221
|
+
command?: string;
|
|
222
|
+
downloadUrl?: string;
|
|
223
|
+
metadata?: Record<string, unknown>;
|
|
224
|
+
}
|
|
225
|
+
export interface RunnerTask {
|
|
226
|
+
taskId: string;
|
|
227
|
+
type: string;
|
|
228
|
+
status: 'running' | 'completed' | 'failed';
|
|
229
|
+
startedAt: number;
|
|
230
|
+
completedAt?: number;
|
|
231
|
+
correlationId?: string;
|
|
232
|
+
metadata?: Record<string, unknown>;
|
|
233
|
+
}
|
|
234
|
+
export interface RunnerInfo {
|
|
235
|
+
runnerId: string;
|
|
236
|
+
name: string;
|
|
237
|
+
endpoint: string;
|
|
238
|
+
version: string;
|
|
239
|
+
capabilities: string[];
|
|
240
|
+
/** Realm templates this runner can spawn. */
|
|
241
|
+
realmTemplates: RealmTemplate[];
|
|
242
|
+
labels: Record<string, string>;
|
|
243
|
+
lastHeartbeat: Date;
|
|
244
|
+
status: 'online' | 'offline';
|
|
245
|
+
resources?: SystemResources;
|
|
246
|
+
tasks: RunnerTask[];
|
|
247
|
+
pendingUpdate?: PendingUpdate;
|
|
248
|
+
}
|
|
249
|
+
export interface RegisterRunnerPayload {
|
|
250
|
+
runnerId?: string;
|
|
251
|
+
name?: string;
|
|
252
|
+
endpoint?: string;
|
|
253
|
+
version?: string;
|
|
254
|
+
capabilities?: string[];
|
|
255
|
+
/** Realm templates this runner can spawn. */
|
|
256
|
+
realmTemplates?: RealmTemplate[];
|
|
257
|
+
labels?: Record<string, string>;
|
|
258
|
+
metadata?: Record<string, unknown>;
|
|
259
|
+
resources?: SystemResources;
|
|
260
|
+
tasks?: RunnerTask[];
|
|
261
|
+
}
|
|
262
|
+
export interface HeartbeatPayload {
|
|
263
|
+
runnerId?: string;
|
|
264
|
+
timestamp?: number;
|
|
265
|
+
status?: string;
|
|
266
|
+
resources?: SystemResources;
|
|
267
|
+
tasks?: RunnerTask[];
|
|
268
|
+
}
|
|
269
|
+
export interface HeartbeatResponse {
|
|
270
|
+
status: string;
|
|
271
|
+
pendingUpdate?: PendingUpdate;
|
|
272
|
+
}
|
|
273
|
+
export interface RequestUpdatePayload {
|
|
274
|
+
version: string;
|
|
275
|
+
command?: string;
|
|
276
|
+
downloadUrl?: string;
|
|
277
|
+
metadata?: Record<string, unknown>;
|
|
278
|
+
}
|
|
10
279
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAA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AAE,UAAU,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAID,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
package/dist/src/types/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Runtime types for the Yggdrasil orchestration system.
|
|
3
|
+
*
|
|
4
|
+
* These types define the wire protocol between Yggdrasil (the controller)
|
|
5
|
+
* and Ratatoskr (the runner daemon). They are consumed by both the
|
|
6
|
+
* controller itself and by custom pools (like Oasis yggdrasil-pool.ts)
|
|
7
|
+
* that embed the controller API.
|
|
3
8
|
*/
|
|
4
9
|
export {};
|
|
5
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theaiinc/yggdrasil",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Distributed runner orchestration —
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Distributed runner orchestration controller — registration, heartbeat, task dispatch, lease management, Realm lifecycle, and Prometheus metrics for Ratatoskr agents",
|
|
5
5
|
"author": "The AI Inc",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/src/index.js",
|
|
9
|
+
"types": "dist/src/index.d.ts",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/theaiinc/yggdrasil.git",
|
|
13
|
+
"directory": "packages/yggdrasil"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/theaiinc/yggdrasil/blob/main/packages/yggdrasil/README.md",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/theaiinc/yggdrasil/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
9
22
|
"scripts": {
|
|
10
23
|
"build": "tsc -p ./tsconfig.json",
|
|
11
24
|
"dev": "nodemon --exec \"node --loader ts-node/esm src/orchestration-controller.ts\"",
|
|
12
25
|
"start": "node dist/src/orchestration-controller.js",
|
|
13
|
-
"test": "
|
|
26
|
+
"test": "vitest run",
|
|
14
27
|
"lint": "eslint . --ext .ts",
|
|
15
28
|
"prepublishOnly": "npm run build"
|
|
16
29
|
},
|
|
@@ -32,10 +45,12 @@
|
|
|
32
45
|
"@types/cors": "^2.8.17",
|
|
33
46
|
"@types/express": "^4.17.21",
|
|
34
47
|
"@types/node": "^20.17.24",
|
|
48
|
+
"@types/supertest": "^7.2.0",
|
|
35
49
|
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
36
50
|
"@typescript-eslint/parser": "^8.26.1",
|
|
37
51
|
"eslint": "^9.22.0",
|
|
38
52
|
"nodemon": "^3.1.0",
|
|
53
|
+
"supertest": "^7.2.2",
|
|
39
54
|
"ts-node": "^10.9.2",
|
|
40
55
|
"typescript": "^5.3.2",
|
|
41
56
|
"vitest": "^3.2.4"
|
|
@@ -45,9 +60,14 @@
|
|
|
45
60
|
},
|
|
46
61
|
"keywords": [
|
|
47
62
|
"ai",
|
|
63
|
+
"agent",
|
|
48
64
|
"orchestration",
|
|
65
|
+
"runner",
|
|
66
|
+
"yggdrasil",
|
|
49
67
|
"ratatoskr",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
68
|
+
"task-dispatch",
|
|
69
|
+
"lease-management",
|
|
70
|
+
"prometheus",
|
|
71
|
+
"distributed-systems"
|
|
52
72
|
]
|
|
53
73
|
}
|