@sesamespace/hivemind 0.1.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/README.md +86 -0
- package/config/TEAM-CHARTER.md +87 -0
- package/config/default.toml +39 -0
- package/dist/__tests__/fleet-integration.test.d.ts +9 -0
- package/dist/__tests__/fleet-integration.test.d.ts.map +1 -0
- package/dist/__tests__/fleet-integration.test.js +201 -0
- package/dist/__tests__/fleet-integration.test.js.map +1 -0
- package/dist/__tests__/fleet.test.d.ts +7 -0
- package/dist/__tests__/fleet.test.d.ts.map +1 -0
- package/dist/__tests__/fleet.test.js +171 -0
- package/dist/__tests__/fleet.test.js.map +1 -0
- package/dist/__tests__/integration.test.d.ts +2 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +348 -0
- package/dist/__tests__/integration.test.js.map +1 -0
- package/dist/agent.d.ts +27 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +217 -0
- package/dist/agent.js.map +1 -0
- package/dist/commands/fleet.d.ts +13 -0
- package/dist/commands/fleet.d.ts.map +1 -0
- package/dist/commands/fleet.js +193 -0
- package/dist/commands/fleet.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +170 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/start.d.ts +2 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +39 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +73 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +50 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +153 -0
- package/dist/context.js.map +1 -0
- package/dist/fleet/fleet-manager.d.ts +86 -0
- package/dist/fleet/fleet-manager.d.ts.map +1 -0
- package/dist/fleet/fleet-manager.js +298 -0
- package/dist/fleet/fleet-manager.js.map +1 -0
- package/dist/fleet/memory-sync.d.ts +91 -0
- package/dist/fleet/memory-sync.d.ts.map +1 -0
- package/dist/fleet/memory-sync.js +292 -0
- package/dist/fleet/memory-sync.js.map +1 -0
- package/dist/fleet/primary-client.d.ts +49 -0
- package/dist/fleet/primary-client.d.ts.map +1 -0
- package/dist/fleet/primary-client.js +222 -0
- package/dist/fleet/primary-client.js.map +1 -0
- package/dist/fleet/worker-protocol.d.ts +125 -0
- package/dist/fleet/worker-protocol.d.ts.map +1 -0
- package/dist/fleet/worker-protocol.js +27 -0
- package/dist/fleet/worker-protocol.js.map +1 -0
- package/dist/fleet/worker-server.d.ts +53 -0
- package/dist/fleet/worker-server.d.ts.map +1 -0
- package/dist/fleet/worker-server.js +191 -0
- package/dist/fleet/worker-server.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm-client.d.ts +24 -0
- package/dist/llm-client.d.ts.map +1 -0
- package/dist/llm-client.js +40 -0
- package/dist/llm-client.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +41 -0
- package/dist/main.js.map +1 -0
- package/dist/memory-client.d.ts +88 -0
- package/dist/memory-client.d.ts.map +1 -0
- package/dist/memory-client.js +185 -0
- package/dist/memory-client.js.map +1 -0
- package/dist/pipeline.d.ts +2 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +125 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/prompt.d.ts +6 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +75 -0
- package/dist/prompt.js.map +1 -0
- package/dist/sesame.d.ts +33 -0
- package/dist/sesame.d.ts.map +1 -0
- package/dist/sesame.js +67 -0
- package/dist/sesame.js.map +1 -0
- package/dist/start.d.ts +3 -0
- package/dist/start.d.ts.map +1 -0
- package/dist/start.js +20 -0
- package/dist/start.js.map +1 -0
- package/dist/task-engine.d.ts +32 -0
- package/dist/task-engine.d.ts.map +1 -0
- package/dist/task-engine.js +80 -0
- package/dist/task-engine.js.map +1 -0
- package/dist/worker.d.ts +73 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +279 -0
- package/dist/worker.js.map +1 -0
- package/install.sh +186 -0
- package/package.json +36 -0
- package/packages/memory/Cargo.lock +6480 -0
- package/packages/memory/Cargo.toml +21 -0
- package/packages/memory/src/src/context.rs +179 -0
- package/packages/memory/src/src/embeddings.rs +51 -0
- package/packages/memory/src/src/main.rs +626 -0
- package/packages/memory/src/src/promotion.rs +637 -0
- package/packages/memory/src/src/scoring.rs +131 -0
- package/packages/memory/src/src/store.rs +460 -0
- package/packages/memory/src/src/tasks.rs +321 -0
package/dist/context.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
const SWITCH_PATTERNS = [
|
|
2
|
+
/^switch\s+to\s+(\S+)/i,
|
|
3
|
+
/^context:\s*(\S+)/i,
|
|
4
|
+
/^@(\S+)\s/,
|
|
5
|
+
/^working\s+on\s+(\S+)/i,
|
|
6
|
+
];
|
|
7
|
+
export class ContextManager {
|
|
8
|
+
contexts = new Map();
|
|
9
|
+
activeContext = "global";
|
|
10
|
+
memory;
|
|
11
|
+
constructor(memory) {
|
|
12
|
+
this.memory = memory;
|
|
13
|
+
// Global context always exists
|
|
14
|
+
this.contexts.set("global", {
|
|
15
|
+
name: "global",
|
|
16
|
+
description: "Global context — identity, preferences, cross-cutting knowledge",
|
|
17
|
+
created_at: new Date().toISOString(),
|
|
18
|
+
last_active: new Date().toISOString(),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async createContext(name, description = "") {
|
|
22
|
+
if (this.contexts.has(name)) {
|
|
23
|
+
return this.contexts.get(name);
|
|
24
|
+
}
|
|
25
|
+
const metadata = {
|
|
26
|
+
name,
|
|
27
|
+
description,
|
|
28
|
+
created_at: new Date().toISOString(),
|
|
29
|
+
last_active: new Date().toISOString(),
|
|
30
|
+
};
|
|
31
|
+
this.contexts.set(name, metadata);
|
|
32
|
+
// Register context with memory daemon
|
|
33
|
+
try {
|
|
34
|
+
await this.memory.createContext(name, description);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(`Failed to register context '${name}' with daemon:`, err.message);
|
|
38
|
+
}
|
|
39
|
+
return metadata;
|
|
40
|
+
}
|
|
41
|
+
async deleteContext(name) {
|
|
42
|
+
if (name === "global") {
|
|
43
|
+
console.error("Cannot delete global context");
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (!this.contexts.has(name)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
this.contexts.delete(name);
|
|
50
|
+
if (this.activeContext === name) {
|
|
51
|
+
this.activeContext = "global";
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
await this.memory.deleteContext(name);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(`Failed to delete context '${name}' from daemon:`, err.message);
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
listContexts() {
|
|
62
|
+
return Array.from(this.contexts.values());
|
|
63
|
+
}
|
|
64
|
+
getContext(name) {
|
|
65
|
+
return this.contexts.get(name);
|
|
66
|
+
}
|
|
67
|
+
getActiveContext() {
|
|
68
|
+
return this.activeContext;
|
|
69
|
+
}
|
|
70
|
+
switchContext(name) {
|
|
71
|
+
const previousContext = this.activeContext;
|
|
72
|
+
const isNew = !this.contexts.has(name);
|
|
73
|
+
if (isNew) {
|
|
74
|
+
this.contexts.set(name, {
|
|
75
|
+
name,
|
|
76
|
+
description: "",
|
|
77
|
+
created_at: new Date().toISOString(),
|
|
78
|
+
last_active: new Date().toISOString(),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
this.activeContext = name;
|
|
82
|
+
this.touchContext(name);
|
|
83
|
+
return { previousContext, activeContext: name, isNew };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse a message and determine if it's a context switch command.
|
|
87
|
+
* Returns the context name if a switch is detected, null otherwise.
|
|
88
|
+
*/
|
|
89
|
+
parseContextSwitch(message) {
|
|
90
|
+
for (const pattern of SWITCH_PATTERNS) {
|
|
91
|
+
const match = message.match(pattern);
|
|
92
|
+
if (match) {
|
|
93
|
+
return match[1].toLowerCase();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Infer context from message content by checking known context names.
|
|
100
|
+
* Returns the best matching context or current active context.
|
|
101
|
+
*/
|
|
102
|
+
inferContext(message) {
|
|
103
|
+
const lower = message.toLowerCase();
|
|
104
|
+
for (const [name] of this.contexts) {
|
|
105
|
+
if (name === "global")
|
|
106
|
+
continue;
|
|
107
|
+
if (lower.includes(name.toLowerCase())) {
|
|
108
|
+
return name;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return this.activeContext;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Route a message: check for explicit switch, then infer context.
|
|
115
|
+
* Returns the resolved context name and whether a switch happened.
|
|
116
|
+
*/
|
|
117
|
+
routeMessage(message) {
|
|
118
|
+
// Check for explicit switch command
|
|
119
|
+
const switchTarget = this.parseContextSwitch(message);
|
|
120
|
+
if (switchTarget) {
|
|
121
|
+
const result = this.switchContext(switchTarget);
|
|
122
|
+
return { context: switchTarget, switched: true, switchedTo: result.activeContext };
|
|
123
|
+
}
|
|
124
|
+
// Infer from content
|
|
125
|
+
const inferred = this.inferContext(message);
|
|
126
|
+
if (inferred !== this.activeContext) {
|
|
127
|
+
this.touchContext(inferred);
|
|
128
|
+
return { context: inferred, switched: false };
|
|
129
|
+
}
|
|
130
|
+
this.touchContext(this.activeContext);
|
|
131
|
+
return { context: this.activeContext, switched: false };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns contexts that should be searched: active context + global.
|
|
135
|
+
*/
|
|
136
|
+
getSearchContexts() {
|
|
137
|
+
const contexts = [this.activeContext];
|
|
138
|
+
if (this.activeContext !== "global") {
|
|
139
|
+
contexts.push("global");
|
|
140
|
+
}
|
|
141
|
+
return contexts;
|
|
142
|
+
}
|
|
143
|
+
hasContext(name) {
|
|
144
|
+
return this.contexts.has(name);
|
|
145
|
+
}
|
|
146
|
+
touchContext(name) {
|
|
147
|
+
const ctx = this.contexts.get(name);
|
|
148
|
+
if (ctx) {
|
|
149
|
+
ctx.last_active = new Date().toISOString();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAeA,MAAM,eAAe,GAAG;IACtB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,wBAAwB;CACzB,CAAC;AAEF,MAAM,OAAO,cAAc;IACjB,QAAQ,GAAiC,IAAI,GAAG,EAAE,CAAC;IACnD,aAAa,GAAW,QAAQ,CAAC;IACjC,MAAM,CAAe;IAE7B,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,+BAA+B;QAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC1B,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iEAAiE;YAC9E,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,WAAW,GAAG,EAAE;QAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAE,C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AK,QAAQ,EAAE,CAAC;YACpC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fleet Manager — high-level orchestration layer on top of PrimaryClient.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Worker provisioning (register by URL)
|
|
6
|
+
* - Context assignment and migration between workers
|
|
7
|
+
* - Aggregate fleet status / dashboard data
|
|
8
|
+
* - Worker discovery and removal
|
|
9
|
+
*/
|
|
10
|
+
import { PrimaryClient } from "./primary-client.js";
|
|
11
|
+
import type { WorkerInfo, WorkerHealthStatus, WorkerCapabilities, ContextAssignResponse, WorkerStatus, WorkerActivity } from "./worker-protocol.js";
|
|
12
|
+
export interface WorkerSummary {
|
|
13
|
+
id: string;
|
|
14
|
+
url: string;
|
|
15
|
+
health: WorkerHealthStatus;
|
|
16
|
+
contexts: string[];
|
|
17
|
+
current_task: string | null;
|
|
18
|
+
activity: WorkerActivity;
|
|
19
|
+
uptime_seconds: number | null;
|
|
20
|
+
capabilities: WorkerCapabilities;
|
|
21
|
+
last_heartbeat: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FleetDashboard {
|
|
24
|
+
total_workers: number;
|
|
25
|
+
healthy: number;
|
|
26
|
+
degraded: number;
|
|
27
|
+
unreachable: number;
|
|
28
|
+
total_contexts: number;
|
|
29
|
+
workers: WorkerSummary[];
|
|
30
|
+
unassigned_contexts: string[];
|
|
31
|
+
generated_at: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MigrationResult {
|
|
34
|
+
context_name: string;
|
|
35
|
+
from_worker: string;
|
|
36
|
+
to_worker: string;
|
|
37
|
+
success: boolean;
|
|
38
|
+
reason?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class FleetManager {
|
|
41
|
+
private primary;
|
|
42
|
+
private latestHealth;
|
|
43
|
+
private latestStatus;
|
|
44
|
+
private knownContexts;
|
|
45
|
+
constructor(primary?: PrimaryClient);
|
|
46
|
+
getPrimary(): PrimaryClient;
|
|
47
|
+
/**
|
|
48
|
+
* Register a new worker by URL. Probes the worker's health endpoint
|
|
49
|
+
* to discover capabilities, then registers it with the Primary.
|
|
50
|
+
*/
|
|
51
|
+
addWorker(url: string): Promise<WorkerInfo>;
|
|
52
|
+
/** Remove a worker from the fleet, unassigning its contexts first. */
|
|
53
|
+
removeWorker(workerId: string): Promise<boolean>;
|
|
54
|
+
/** Assign a context to a specific worker. */
|
|
55
|
+
assignContext(workerId: string, contextName: string, description?: string): Promise<ContextAssignResponse>;
|
|
56
|
+
/** Migrate a context from one worker to another. */
|
|
57
|
+
migrateContext(contextName: string, toWorkerId: string): Promise<MigrationResult>;
|
|
58
|
+
/** Refresh health for all workers. */
|
|
59
|
+
refreshHealth(): Promise<void>;
|
|
60
|
+
/** Record a status report (called when worker POSTs status to Primary). */
|
|
61
|
+
recordStatus(workerId: string, status: WorkerStatus): void;
|
|
62
|
+
/** Get the full fleet dashboard. */
|
|
63
|
+
getDashboard(): Promise<FleetDashboard>;
|
|
64
|
+
/** Get a quick status summary without refreshing health. */
|
|
65
|
+
getStatusSnapshot(): FleetDashboard;
|
|
66
|
+
/**
|
|
67
|
+
* Scan a list of candidate URLs for workers. Returns the URLs
|
|
68
|
+
* that responded to a health probe. Useful for auto-detecting
|
|
69
|
+
* workers on a local network.
|
|
70
|
+
*/
|
|
71
|
+
discoverWorkers(candidateUrls: string[]): Promise<string[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Scan a subnet-style range for workers. Generates URLs for
|
|
74
|
+
* a base IP with ports and probes them.
|
|
75
|
+
* Example: scanSubnet("192.168.1", [10, 11, 12], 3100)
|
|
76
|
+
*/
|
|
77
|
+
scanSubnet(baseIp: string, hostIds: number[], port: number): Promise<string[]>;
|
|
78
|
+
/** Track a context name so it appears in unassigned lists. */
|
|
79
|
+
registerContext(contextName: string): void;
|
|
80
|
+
/** Start health polling (delegates to PrimaryClient). */
|
|
81
|
+
startHealthPolling(intervalMs?: number): void;
|
|
82
|
+
/** Stop health polling. */
|
|
83
|
+
stopHealthPolling(): void;
|
|
84
|
+
private probeWorker;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=fleet-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-manager.d.ts","sourceRoot":"","sources":["../../src/fleet/fleet-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,KAAK,EACV,UAAU,EAEV,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACf,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,cAAc,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,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,CAAC;IAiD7C,4DAA4D;IAC5D,iBAAiB,IAAI,cAAc;IAgDnC;;;;OAIG;IACG,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA0BjE;;;;OAIG;IACG,UAAU,CACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,EAAE,CAAC;IAKpB,8DAA8D;IAC9D,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI1C,yDAAyD;IACzD,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7C,2BAA2B;IAC3B,iBAAiB,IAAI,IAAI;YAMX,WAAW;CA+B1B"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fleet Manager — high-level orchestration layer on top of PrimaryClient.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Worker provisioning (register by URL)
|
|
6
|
+
* - Context assignment and migration between workers
|
|
7
|
+
* - Aggregate fleet status / dashboard data
|
|
8
|
+
* - Worker discovery and removal
|
|
9
|
+
*/
|
|
10
|
+
import { PrimaryClient } from "./primary-client.js";
|
|
11
|
+
import { WORKER_ROUTES, HEALTH_TIMEOUT_MS, } from "./worker-protocol.js";
|
|
12
|
+
export class FleetManager {
|
|
13
|
+
primary;
|
|
14
|
+
latestHealth = new Map();
|
|
15
|
+
latestStatus = new Map();
|
|
16
|
+
knownContexts = new Set();
|
|
17
|
+
constructor(primary) {
|
|
18
|
+
this.primary = primary ?? new PrimaryClient();
|
|
19
|
+
}
|
|
20
|
+
getPrimary() {
|
|
21
|
+
return this.primary;
|
|
22
|
+
}
|
|
23
|
+
// --- Worker Provisioning ---
|
|
24
|
+
/**
|
|
25
|
+
* Register a new worker by URL. Probes the worker's health endpoint
|
|
26
|
+
* to discover capabilities, then registers it with the Primary.
|
|
27
|
+
*/
|
|
28
|
+
async addWorker(url) {
|
|
29
|
+
// Normalise trailing slash
|
|
30
|
+
const baseUrl = url.replace(/\/+$/, "");
|
|
31
|
+
// Probe worker health to discover capabilities
|
|
32
|
+
const capabilities = await this.probeWorker(baseUrl);
|
|
33
|
+
const reg = this.primary.handleRegistration({ url: baseUrl, capabilities });
|
|
34
|
+
const worker = this.primary.getWorker(reg.worker_id);
|
|
35
|
+
if (!worker) {
|
|
36
|
+
throw new Error("Worker registered but not found in registry");
|
|
37
|
+
}
|
|
38
|
+
return worker;
|
|
39
|
+
}
|
|
40
|
+
/** Remove a worker from the fleet, unassigning its contexts first. */
|
|
41
|
+
async removeWorker(workerId) {
|
|
42
|
+
const worker = this.primary.getWorker(workerId);
|
|
43
|
+
if (!worker)
|
|
44
|
+
return false;
|
|
45
|
+
// Unassign all contexts from this worker
|
|
46
|
+
for (const ctx of [...worker.assigned_contexts]) {
|
|
47
|
+
await this.primary.unassignContext(workerId, ctx);
|
|
48
|
+
}
|
|
49
|
+
return this.primary.deregister(workerId);
|
|
50
|
+
}
|
|
51
|
+
// --- Context Assignment ---
|
|
52
|
+
/** Assign a context to a specific worker. */
|
|
53
|
+
async assignContext(workerId, contextName, description = "") {
|
|
54
|
+
const result = await this.primary.assignContext(workerId, contextName, description);
|
|
55
|
+
if (result.accepted) {
|
|
56
|
+
this.knownContexts.add(contextName);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
/** Migrate a context from one worker to another. */
|
|
61
|
+
async migrateContext(contextName, toWorkerId) {
|
|
62
|
+
const fromWorker = this.primary.findWorkerForContext(contextName);
|
|
63
|
+
if (!fromWorker) {
|
|
64
|
+
// Context isn't assigned anywhere — just assign to target
|
|
65
|
+
const resp = await this.primary.assignContext(toWorkerId, contextName);
|
|
66
|
+
return {
|
|
67
|
+
context_name: contextName,
|
|
68
|
+
from_worker: "(none)",
|
|
69
|
+
to_worker: toWorkerId,
|
|
70
|
+
success: resp.accepted,
|
|
71
|
+
reason: resp.accepted ? undefined : resp.reason,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (fromWorker.id === toWorkerId) {
|
|
75
|
+
return {
|
|
76
|
+
context_name: contextName,
|
|
77
|
+
from_worker: fromWorker.id,
|
|
78
|
+
to_worker: toWorkerId,
|
|
79
|
+
success: false,
|
|
80
|
+
reason: "Context already assigned to this worker",
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Assign to new worker first, then unassign from old
|
|
84
|
+
const assignResult = await this.primary.assignContext(toWorkerId, contextName);
|
|
85
|
+
if (!assignResult.accepted) {
|
|
86
|
+
return {
|
|
87
|
+
context_name: contextName,
|
|
88
|
+
from_worker: fromWorker.id,
|
|
89
|
+
to_worker: toWorkerId,
|
|
90
|
+
success: false,
|
|
91
|
+
reason: assignResult.reason ?? "Target worker rejected assignment",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
await this.primary.unassignContext(fromWorker.id, contextName);
|
|
95
|
+
return {
|
|
96
|
+
context_name: contextName,
|
|
97
|
+
from_worker: fromWorker.id,
|
|
98
|
+
to_worker: toWorkerId,
|
|
99
|
+
success: true,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// --- Status & Health ---
|
|
103
|
+
/** Refresh health for all workers. */
|
|
104
|
+
async refreshHealth() {
|
|
105
|
+
const workers = this.primary.getWorkers();
|
|
106
|
+
const checks = workers.map(async (w) => {
|
|
107
|
+
const health = await this.primary.checkHealth(w.id);
|
|
108
|
+
if (health) {
|
|
109
|
+
this.latestHealth.set(w.id, health);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// Mark unreachable but keep stale data
|
|
113
|
+
this.latestHealth.set(w.id, {
|
|
114
|
+
worker_id: w.id,
|
|
115
|
+
status: "unreachable",
|
|
116
|
+
uptime_seconds: 0,
|
|
117
|
+
assigned_contexts: w.assigned_contexts,
|
|
118
|
+
active_context: null,
|
|
119
|
+
memory_daemon_ok: false,
|
|
120
|
+
ollama_ok: false,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
await Promise.all(checks);
|
|
125
|
+
}
|
|
126
|
+
/** Record a status report (called when worker POSTs status to Primary). */
|
|
127
|
+
recordStatus(workerId, status) {
|
|
128
|
+
this.latestStatus.set(workerId, status);
|
|
129
|
+
}
|
|
130
|
+
/** Get the full fleet dashboard. */
|
|
131
|
+
async getDashboard() {
|
|
132
|
+
await this.refreshHealth();
|
|
133
|
+
const workers = this.primary.getWorkers();
|
|
134
|
+
let healthy = 0;
|
|
135
|
+
let degraded = 0;
|
|
136
|
+
let unreachable = 0;
|
|
137
|
+
let totalContexts = 0;
|
|
138
|
+
const workerSummaries = workers.map((w) => {
|
|
139
|
+
const health = this.latestHealth.get(w.id);
|
|
140
|
+
const status = this.latestStatus.get(w.id);
|
|
141
|
+
const healthStatus = health?.status ?? "unreachable";
|
|
142
|
+
if (healthStatus === "healthy")
|
|
143
|
+
healthy++;
|
|
144
|
+
else if (healthStatus === "degraded")
|
|
145
|
+
degraded++;
|
|
146
|
+
else
|
|
147
|
+
unreachable++;
|
|
148
|
+
totalContexts += w.assigned_contexts.length;
|
|
149
|
+
return {
|
|
150
|
+
id: w.id,
|
|
151
|
+
url: w.url,
|
|
152
|
+
health: healthStatus,
|
|
153
|
+
contexts: w.assigned_contexts,
|
|
154
|
+
current_task: status?.current_task ?? null,
|
|
155
|
+
activity: status?.activity ?? "idle",
|
|
156
|
+
uptime_seconds: health?.uptime_seconds ?? null,
|
|
157
|
+
capabilities: w.capabilities,
|
|
158
|
+
last_heartbeat: w.last_heartbeat,
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
// Determine unassigned contexts
|
|
162
|
+
const assignedContexts = new Set(workers.flatMap((w) => w.assigned_contexts));
|
|
163
|
+
const unassigned = [...this.knownContexts].filter((c) => !assignedContexts.has(c));
|
|
164
|
+
return {
|
|
165
|
+
total_workers: workers.length,
|
|
166
|
+
healthy,
|
|
167
|
+
degraded,
|
|
168
|
+
unreachable,
|
|
169
|
+
total_contexts: totalContexts,
|
|
170
|
+
workers: workerSummaries,
|
|
171
|
+
unassigned_contexts: unassigned,
|
|
172
|
+
generated_at: new Date().toISOString(),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** Get a quick status summary without refreshing health. */
|
|
176
|
+
getStatusSnapshot() {
|
|
177
|
+
const workers = this.primary.getWorkers();
|
|
178
|
+
let healthy = 0;
|
|
179
|
+
let degraded = 0;
|
|
180
|
+
let unreachable = 0;
|
|
181
|
+
let totalContexts = 0;
|
|
182
|
+
const workerSummaries = workers.map((w) => {
|
|
183
|
+
const health = this.latestHealth.get(w.id);
|
|
184
|
+
const status = this.latestStatus.get(w.id);
|
|
185
|
+
const healthStatus = health?.status ?? "unreachable";
|
|
186
|
+
if (healthStatus === "healthy")
|
|
187
|
+
healthy++;
|
|
188
|
+
else if (healthStatus === "degraded")
|
|
189
|
+
degraded++;
|
|
190
|
+
else
|
|
191
|
+
unreachable++;
|
|
192
|
+
totalContexts += w.assigned_contexts.length;
|
|
193
|
+
return {
|
|
194
|
+
id: w.id,
|
|
195
|
+
url: w.url,
|
|
196
|
+
health: healthStatus,
|
|
197
|
+
contexts: w.assigned_contexts,
|
|
198
|
+
current_task: status?.current_task ?? null,
|
|
199
|
+
activity: status?.activity ?? "idle",
|
|
200
|
+
uptime_seconds: health?.uptime_seconds ?? null,
|
|
201
|
+
capabilities: w.capabilities,
|
|
202
|
+
last_heartbeat: w.last_heartbeat,
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
const assignedContexts = new Set(workers.flatMap((w) => w.assigned_contexts));
|
|
206
|
+
const unassigned = [...this.knownContexts].filter((c) => !assignedContexts.has(c));
|
|
207
|
+
return {
|
|
208
|
+
total_workers: workers.length,
|
|
209
|
+
healthy,
|
|
210
|
+
degraded,
|
|
211
|
+
unreachable,
|
|
212
|
+
total_contexts: totalContexts,
|
|
213
|
+
workers: workerSummaries,
|
|
214
|
+
unassigned_contexts: unassigned,
|
|
215
|
+
generated_at: new Date().toISOString(),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// --- Worker Discovery ---
|
|
219
|
+
/**
|
|
220
|
+
* Scan a list of candidate URLs for workers. Returns the URLs
|
|
221
|
+
* that responded to a health probe. Useful for auto-detecting
|
|
222
|
+
* workers on a local network.
|
|
223
|
+
*/
|
|
224
|
+
async discoverWorkers(candidateUrls) {
|
|
225
|
+
const found = [];
|
|
226
|
+
const probes = candidateUrls.map(async (url) => {
|
|
227
|
+
const baseUrl = url.replace(/\/+$/, "");
|
|
228
|
+
try {
|
|
229
|
+
const controller = new AbortController();
|
|
230
|
+
const timeout = setTimeout(() => controller.abort(), HEALTH_TIMEOUT_MS);
|
|
231
|
+
const resp = await fetch(`${baseUrl}${WORKER_ROUTES.health}`, {
|
|
232
|
+
signal: controller.signal,
|
|
233
|
+
});
|
|
234
|
+
clearTimeout(timeout);
|
|
235
|
+
if (resp.ok) {
|
|
236
|
+
found.push(baseUrl);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Not reachable, skip
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
await Promise.all(probes);
|
|
244
|
+
return found;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Scan a subnet-style range for workers. Generates URLs for
|
|
248
|
+
* a base IP with ports and probes them.
|
|
249
|
+
* Example: scanSubnet("192.168.1", [10, 11, 12], 3100)
|
|
250
|
+
*/
|
|
251
|
+
async scanSubnet(baseIp, hostIds, port) {
|
|
252
|
+
const urls = hostIds.map((id) => `http://${baseIp}.${id}:${port}`);
|
|
253
|
+
return this.discoverWorkers(urls);
|
|
254
|
+
}
|
|
255
|
+
/** Track a context name so it appears in unassigned lists. */
|
|
256
|
+
registerContext(contextName) {
|
|
257
|
+
this.knownContexts.add(contextName);
|
|
258
|
+
}
|
|
259
|
+
/** Start health polling (delegates to PrimaryClient). */
|
|
260
|
+
startHealthPolling(intervalMs) {
|
|
261
|
+
this.primary.startHealthPolling(intervalMs);
|
|
262
|
+
}
|
|
263
|
+
/** Stop health polling. */
|
|
264
|
+
stopHealthPolling() {
|
|
265
|
+
this.primary.stopHealthPolling();
|
|
266
|
+
}
|
|
267
|
+
// --- Internal ---
|
|
268
|
+
async probeWorker(baseUrl) {
|
|
269
|
+
try {
|
|
270
|
+
const controller = new AbortController();
|
|
271
|
+
const timeout = setTimeout(() => controller.abort(), HEALTH_TIMEOUT_MS);
|
|
272
|
+
const resp = await fetch(`${baseUrl}${WORKER_ROUTES.health}`, {
|
|
273
|
+
signal: controller.signal,
|
|
274
|
+
});
|
|
275
|
+
clearTimeout(timeout);
|
|
276
|
+
if (resp.ok) {
|
|
277
|
+
const health = (await resp.json());
|
|
278
|
+
return {
|
|
279
|
+
max_contexts: health.assigned_contexts.length + 4, // assume capacity
|
|
280
|
+
has_ollama: health.ollama_ok,
|
|
281
|
+
has_memory_daemon: health.memory_daemon_ok,
|
|
282
|
+
available_models: [],
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
// Fall through to defaults
|
|
288
|
+
}
|
|
289
|
+
// Return default capabilities if probe fails
|
|
290
|
+
return {
|
|
291
|
+
max_contexts: 4,
|
|
292
|
+
has_ollama: false,
|
|
293
|
+
has_memory_daemon: false,
|
|
294
|
+
available_models: [],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=fleet-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-manager.js","sourceRoot":"","sources":["../../src/fleet/fleet-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AA4C9B,MAAM,OAAO,YAA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AC7C,OAAO;YACL,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,KAAK;YACjB,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,EAAE;SACrB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-machine memory sync.
|
|
3
|
+
*
|
|
4
|
+
* Workers periodically push key L3 knowledge back to the Primary.
|
|
5
|
+
* Primary can push Global context updates (L3 + L2 episodes) to workers.
|
|
6
|
+
*
|
|
7
|
+
* Conflict resolution:
|
|
8
|
+
* - L3: last-write-wins (compared by updated_at timestamp)
|
|
9
|
+
* - L2: append-only (episodes are never overwritten, only added)
|
|
10
|
+
*
|
|
11
|
+
* Sync protocol:
|
|
12
|
+
* POST /sync/pull — Worker sends L3 knowledge to Primary
|
|
13
|
+
* POST /sync/push — Primary sends Global context updates to Worker
|
|
14
|
+
*/
|
|
15
|
+
import type { MemoryClient } from "../memory-client.js";
|
|
16
|
+
import type { PrimaryClient } from "./primary-client.js";
|
|
17
|
+
import type { WorkerServer } from "./worker-server.js";
|
|
18
|
+
import type { SyncPullRequest, SyncPullResponse, SyncPushRequest, SyncPushResponse, SyncL3Entry } from "./worker-protocol.js";
|
|
19
|
+
export interface WorkerSyncOptions {
|
|
20
|
+
workerId: string;
|
|
21
|
+
primaryUrl: string;
|
|
22
|
+
memory: MemoryClient;
|
|
23
|
+
server: WorkerServer;
|
|
24
|
+
syncIntervalMs?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Worker-side memory sync. Periodically sends L3 knowledge from assigned
|
|
28
|
+
* contexts back to the Primary, and accepts Global context pushes.
|
|
29
|
+
*/
|
|
30
|
+
export declare class WorkerMemorySync {
|
|
31
|
+
private workerId;
|
|
32
|
+
private primaryUrl;
|
|
33
|
+
private memory;
|
|
34
|
+
private syncTimer;
|
|
35
|
+
private syncIntervalMs;
|
|
36
|
+
private knownL2Ids;
|
|
37
|
+
private knownL3Ids;
|
|
38
|
+
constructor(opts: WorkerSyncOptions);
|
|
39
|
+
/** Start periodic sync (Worker -> Primary). */
|
|
40
|
+
start(contextNames: () => string[]): void;
|
|
41
|
+
/** Stop periodic sync. */
|
|
42
|
+
stop(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Pull L3 knowledge from all assigned contexts and send to Primary.
|
|
45
|
+
* Called periodically by the sync timer.
|
|
46
|
+
*/
|
|
47
|
+
pullTowardsPrimary(contextNames: string[]): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Handle an incoming push of Global context updates from the Primary.
|
|
50
|
+
* L3: last-write-wins. L2: append-only.
|
|
51
|
+
*/
|
|
52
|
+
handlePush(req: SyncPushRequest): Promise<SyncPushResponse>;
|
|
53
|
+
getSyncIntervalMs(): number;
|
|
54
|
+
}
|
|
55
|
+
export interface PrimarySyncOptions {
|
|
56
|
+
primary: PrimaryClient;
|
|
57
|
+
memory: MemoryClient;
|
|
58
|
+
syncIntervalMs?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Primary-side memory sync. Handles incoming L3 pulls from workers and
|
|
62
|
+
* can push Global context updates out to all workers.
|
|
63
|
+
*/
|
|
64
|
+
export declare class PrimaryMemorySync {
|
|
65
|
+
private primary;
|
|
66
|
+
private memory;
|
|
67
|
+
private syncIntervalMs;
|
|
68
|
+
private pushTimer;
|
|
69
|
+
private l3Store;
|
|
70
|
+
private lastPushAt;
|
|
71
|
+
constructor(opts: PrimarySyncOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Handle an incoming pull — Worker sending L3 knowledge to Primary.
|
|
74
|
+
* Uses last-write-wins for conflict resolution.
|
|
75
|
+
*/
|
|
76
|
+
handlePull(req: SyncPullRequest): Promise<SyncPullResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Push Global context updates to all workers.
|
|
79
|
+
* Fetches current Global L3 knowledge and recent L2 episodes,
|
|
80
|
+
* then pushes to every registered worker.
|
|
81
|
+
*/
|
|
82
|
+
pushGlobalToAll(): Promise<Map<string, SyncPushResponse | null>>;
|
|
83
|
+
/** Start periodic Global push to all workers. */
|
|
84
|
+
startPushLoop(): void;
|
|
85
|
+
/** Stop periodic push. */
|
|
86
|
+
stopPushLoop(): void;
|
|
87
|
+
/** Get all synced L3 entries the Primary has received. */
|
|
88
|
+
getSyncedEntries(): SyncL3Entry[];
|
|
89
|
+
getSyncIntervalMs(): number;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=memory-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-sync.d.ts","sourceRoot":"","sources":["../../src/fleet/memory-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EAEZ,MAAM,sBAAsB,CAAC;AA8B9B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,UAAU,CAAkC;gBAExC,IAAI,EAAE,iBAAiB;IAUnC,+CAA+C;IAC/C,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