@sesamespace/hivemind 0.4.3 → 0.5.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/dist/{chunk-2OIRJFI5.js → chunk-3T6RYEZF.js} +9 -5
- package/dist/chunk-3T6RYEZF.js.map +1 -0
- package/dist/{chunk-O257FXSX.js → chunk-LNV373IF.js} +27 -2
- package/dist/chunk-LNV373IF.js.map +1 -0
- package/dist/chunk-PPQGQHXJ.js +151 -0
- package/dist/chunk-PPQGQHXJ.js.map +1 -0
- package/dist/commands/init.js +1 -1
- package/dist/commands/service.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/main.js +3 -3
- package/install.sh +55 -122
- package/package.json +1 -1
- package/packages/cli/src/commands/init.ts +8 -4
- package/packages/cli/src/commands/service.ts +91 -73
- package/packages/cli/src/commands/start.ts +37 -1
- package/dist/README.md +0 -116
- package/dist/chunk-2OIRJFI5.js.map +0 -1
- package/dist/chunk-MBS5A6BZ.js +0 -132
- package/dist/chunk-MBS5A6BZ.js.map +0 -1
- package/dist/chunk-O257FXSX.js.map +0 -1
- package/dist/config/TEAM-CHARTER.md +0 -87
- package/dist/config/default.toml +0 -39
- package/dist/package.json +0 -26
|
@@ -1,21 +1,69 @@
|
|
|
1
1
|
import { resolve } from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { writeFileSync, existsSync, unlinkSync, mkdirSync } from "fs";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
4
|
import { homedir } from "os";
|
|
5
5
|
|
|
6
6
|
const LAUNCH_AGENTS_DIR = resolve(homedir(), "Library/LaunchAgents");
|
|
7
7
|
const AGENT_LABEL = "com.hivemind.agent";
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
function getHivemindHome(): string {
|
|
10
|
+
return process.env.HIVEMIND_HOME || resolve(homedir(), "hivemind");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getHivemindBin(): string {
|
|
14
|
+
// Try to find the hivemind binary
|
|
15
|
+
try {
|
|
16
|
+
const which = execSync("which hivemind", { encoding: "utf-8" }).trim();
|
|
17
|
+
if (which) return which;
|
|
18
|
+
} catch {}
|
|
19
|
+
// Fallback to process.argv[1] (the script being run)
|
|
20
|
+
return process.argv[1] || "hivemind";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function generatePlist(hivemindHome: string, hivemindBin: string): string {
|
|
24
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
26
|
+
<plist version="1.0">
|
|
27
|
+
<dict>
|
|
28
|
+
<key>Label</key>
|
|
29
|
+
<string>${AGENT_LABEL}</string>
|
|
30
|
+
<key>ProgramArguments</key>
|
|
31
|
+
<array>
|
|
32
|
+
<string>${hivemindBin}</string>
|
|
33
|
+
<string>start</string>
|
|
34
|
+
</array>
|
|
35
|
+
<key>WorkingDirectory</key>
|
|
36
|
+
<string>${hivemindHome}</string>
|
|
37
|
+
<key>EnvironmentVariables</key>
|
|
38
|
+
<dict>
|
|
39
|
+
<key>PATH</key>
|
|
40
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
|
|
41
|
+
<key>HIVEMIND_HOME</key>
|
|
42
|
+
<string>${hivemindHome}</string>
|
|
43
|
+
</dict>
|
|
44
|
+
<key>RunAtLoad</key>
|
|
45
|
+
<true/>
|
|
46
|
+
<key>KeepAlive</key>
|
|
47
|
+
<true/>
|
|
48
|
+
<key>StandardOutPath</key>
|
|
49
|
+
<string>/tmp/hivemind-agent.log</string>
|
|
50
|
+
<key>StandardErrorPath</key>
|
|
51
|
+
<string>/tmp/hivemind-error.log</string>
|
|
52
|
+
<key>ThrottleInterval</key>
|
|
53
|
+
<integer>5</integer>
|
|
54
|
+
</dict>
|
|
55
|
+
</plist>`;
|
|
56
|
+
}
|
|
9
57
|
|
|
10
58
|
export async function runServiceCommand(args: string[]): Promise<void> {
|
|
11
59
|
const subcommand = args[0];
|
|
12
60
|
|
|
13
61
|
switch (subcommand) {
|
|
14
62
|
case "install":
|
|
15
|
-
await
|
|
63
|
+
await installService();
|
|
16
64
|
break;
|
|
17
65
|
case "uninstall":
|
|
18
|
-
await
|
|
66
|
+
await uninstallService();
|
|
19
67
|
break;
|
|
20
68
|
case "status":
|
|
21
69
|
showStatus();
|
|
@@ -33,84 +81,59 @@ export async function runServiceCommand(args: string[]): Promise<void> {
|
|
|
33
81
|
}
|
|
34
82
|
}
|
|
35
83
|
|
|
36
|
-
async function
|
|
37
|
-
const hivemindHome =
|
|
84
|
+
async function installService(): Promise<void> {
|
|
85
|
+
const hivemindHome = getHivemindHome();
|
|
86
|
+
const hivemindBin = getHivemindBin();
|
|
38
87
|
|
|
39
|
-
console.log(`\n→ Installing launchd
|
|
88
|
+
console.log(`\n→ Installing launchd service for ${hivemindHome}\n`);
|
|
89
|
+
console.log(` Binary: ${hivemindBin}`);
|
|
40
90
|
|
|
41
91
|
mkdirSync(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
42
92
|
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
resolve(hivemindHome, "scripts"),
|
|
46
|
-
resolve(dirname(dirname(dirname(fileURLToPath(import.meta.url)))), "scripts"),
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
for (const label of [MEMORY_LABEL, AGENT_LABEL]) {
|
|
50
|
-
const plistFile = `${label}.plist`;
|
|
51
|
-
let templatePath = "";
|
|
52
|
-
|
|
53
|
-
for (const dir of scriptDirs) {
|
|
54
|
-
const p = resolve(dir, plistFile);
|
|
55
|
-
if (existsSync(p)) { templatePath = p; break; }
|
|
56
|
-
}
|
|
93
|
+
const plistContent = generatePlist(hivemindHome, hivemindBin);
|
|
94
|
+
const destPath = resolve(LAUNCH_AGENTS_DIR, `${AGENT_LABEL}.plist`);
|
|
57
95
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
96
|
+
// Unload if already loaded
|
|
97
|
+
try { execSync(`launchctl unload ${destPath} 2>/dev/null`); } catch {}
|
|
62
98
|
|
|
63
|
-
|
|
64
|
-
|
|
99
|
+
writeFileSync(destPath, plistContent);
|
|
100
|
+
execSync(`launchctl load ${destPath}`);
|
|
65
101
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Unload if already loaded, then load
|
|
70
|
-
try { execSync(`launchctl unload ${destPath} 2>/dev/null`); } catch {}
|
|
71
|
-
execSync(`launchctl load ${destPath}`);
|
|
72
|
-
|
|
73
|
-
console.log(` ✓ ${label} installed and started`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log("\n Services will auto-start on boot.\n");
|
|
102
|
+
console.log(` ✓ ${AGENT_LABEL} installed and started`);
|
|
103
|
+
console.log("\n Service will auto-start on boot.");
|
|
104
|
+
console.log(" Logs: /tmp/hivemind-agent.log, /tmp/hivemind-error.log\n");
|
|
77
105
|
}
|
|
78
106
|
|
|
79
|
-
async function
|
|
80
|
-
console.log("\n→ Uninstalling launchd
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} else {
|
|
90
|
-
console.log(` - ${label} not installed`);
|
|
91
|
-
}
|
|
107
|
+
async function uninstallService(): Promise<void> {
|
|
108
|
+
console.log("\n→ Uninstalling launchd service\n");
|
|
109
|
+
|
|
110
|
+
const plistPath = resolve(LAUNCH_AGENTS_DIR, `${AGENT_LABEL}.plist`);
|
|
111
|
+
if (existsSync(plistPath)) {
|
|
112
|
+
try { execSync(`launchctl unload ${plistPath} 2>/dev/null`); } catch {}
|
|
113
|
+
unlinkSync(plistPath);
|
|
114
|
+
console.log(` ✓ ${AGENT_LABEL} uninstalled`);
|
|
115
|
+
} else {
|
|
116
|
+
console.log(` - ${AGENT_LABEL} not installed`);
|
|
92
117
|
}
|
|
93
118
|
console.log("");
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
function showStatus(): void {
|
|
97
122
|
console.log("\n→ Service status\n");
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
console.log(` - ${label}: not running`);
|
|
106
|
-
}
|
|
123
|
+
try {
|
|
124
|
+
const out = execSync(`launchctl list ${AGENT_LABEL} 2>/dev/null`, { encoding: "utf-8" });
|
|
125
|
+
const pidMatch = out.match(/"PID"\s*=\s*(\d+)/);
|
|
126
|
+
const pid = pidMatch ? pidMatch[1] : "unknown";
|
|
127
|
+
console.log(` ✓ ${AGENT_LABEL}: running (PID ${pid})`);
|
|
128
|
+
} catch {
|
|
129
|
+
console.log(` - ${AGENT_LABEL}: not running`);
|
|
107
130
|
}
|
|
108
131
|
console.log("");
|
|
109
132
|
}
|
|
110
133
|
|
|
111
134
|
function showLogs(which?: string): void {
|
|
112
|
-
const logFile = which === "
|
|
113
|
-
? "/tmp/hivemind-
|
|
135
|
+
const logFile = which === "error"
|
|
136
|
+
? "/tmp/hivemind-error.log"
|
|
114
137
|
: "/tmp/hivemind-agent.log";
|
|
115
138
|
try {
|
|
116
139
|
execSync(`tail -30 ${logFile}`, { stdio: "inherit" });
|
|
@@ -120,22 +143,17 @@ function showLogs(which?: string): void {
|
|
|
120
143
|
}
|
|
121
144
|
|
|
122
145
|
function printHelp(): void {
|
|
123
|
-
console.log(`hivemind service — Manage launchd
|
|
146
|
+
console.log(`hivemind service — Manage launchd service
|
|
124
147
|
|
|
125
148
|
Usage: hivemind service <subcommand>
|
|
126
149
|
|
|
127
150
|
Subcommands:
|
|
128
|
-
install Install and start launchd
|
|
129
|
-
uninstall Stop and remove launchd
|
|
151
|
+
install Install and start launchd service (survives reboots)
|
|
152
|
+
uninstall Stop and remove launchd service
|
|
130
153
|
status Show service status
|
|
131
|
-
logs [agent|
|
|
154
|
+
logs [agent|error] Show recent logs
|
|
132
155
|
|
|
133
|
-
|
|
134
|
-
com.hivemind.
|
|
135
|
-
com.hivemind.agent — Agent runtime (Node.js, Sesame)
|
|
156
|
+
Service:
|
|
157
|
+
com.hivemind.agent — Agent runtime (Node.js, Sesame)
|
|
136
158
|
`);
|
|
137
159
|
}
|
|
138
|
-
|
|
139
|
-
// Helpers for ESM
|
|
140
|
-
import { fileURLToPath } from "url";
|
|
141
|
-
import { dirname } from "path";
|
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
import { resolve } from "path";
|
|
2
|
-
import { existsSync } from "fs";
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { homedir } from "os";
|
|
3
4
|
import { startPipeline } from "@hivemind/runtime";
|
|
4
5
|
|
|
5
6
|
const DEFAULT_CONFIG = "config/default.toml";
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Load .env file from HIVEMIND_HOME, setting any missing env vars.
|
|
10
|
+
* Simple KEY=VALUE parser — no dotenv dependency needed.
|
|
11
|
+
*/
|
|
12
|
+
function loadEnvFile(dir: string): void {
|
|
13
|
+
const envPath = resolve(dir, ".env");
|
|
14
|
+
if (!existsSync(envPath)) return;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const content = readFileSync(envPath, "utf-8");
|
|
18
|
+
for (const line of content.split("\n")) {
|
|
19
|
+
const trimmed = line.trim();
|
|
20
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
21
|
+
const eqIdx = trimmed.indexOf("=");
|
|
22
|
+
if (eqIdx < 1) continue;
|
|
23
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
24
|
+
let value = trimmed.slice(eqIdx + 1).trim();
|
|
25
|
+
// Strip surrounding quotes
|
|
26
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
27
|
+
value = value.slice(1, -1);
|
|
28
|
+
}
|
|
29
|
+
// Don't overwrite existing env vars
|
|
30
|
+
if (!(key in process.env)) {
|
|
31
|
+
process.env[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
// Silently ignore read errors
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
7
39
|
export async function runStartCommand(args: string[]): Promise<void> {
|
|
40
|
+
// Load .env from HIVEMIND_HOME before anything else
|
|
41
|
+
const hivemindHome = process.env.HIVEMIND_HOME || resolve(homedir(), "hivemind");
|
|
42
|
+
loadEnvFile(hivemindHome);
|
|
43
|
+
|
|
8
44
|
let configPath = DEFAULT_CONFIG;
|
|
9
45
|
|
|
10
46
|
// Parse args
|
package/dist/README.md
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Hivemind
|
|
2
|
-
|
|
3
|
-
Cognitive architecture for AI agents with multi-layered memory, context isolation, and multi-machine fleet distribution.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
### One-Command Install (recommended)
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
curl -sL api.sesame.space/api/v1/hivemind/install | bash -s -- <your-sesame-api-key>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
This installs all dependencies, configures the agent from Sesame, and starts it.
|
|
14
|
-
|
|
15
|
-
### Manual Install
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
# Install the CLI
|
|
19
|
-
npm install -g @sesamespace/hivemind
|
|
20
|
-
|
|
21
|
-
# Initialize from your Sesame API key
|
|
22
|
-
hivemind init <your-sesame-api-key>
|
|
23
|
-
|
|
24
|
-
# Start the agent
|
|
25
|
-
hivemind start --config config/default.toml
|
|
26
|
-
|
|
27
|
-
# (Optional) Install as a service that survives reboots
|
|
28
|
-
hivemind service install
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Development Install
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
git clone https://github.com/baileydavis2026/hivemind.git
|
|
35
|
-
cd hivemind
|
|
36
|
-
pnpm install
|
|
37
|
-
pnpm build
|
|
38
|
-
cd packages/memory && cargo build --release && cd ../..
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## What You Need
|
|
42
|
-
|
|
43
|
-
- **macOS** (Apple Silicon recommended)
|
|
44
|
-
- **Sesame API key** — get one at [sesame.space](https://sesame.space)
|
|
45
|
-
- **OpenRouter API key** — get one at [openrouter.ai](https://openrouter.ai) (or provision via Sesame vault)
|
|
46
|
-
|
|
47
|
-
## Architecture
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
┌─────────────────────────────────────────┐
|
|
51
|
-
│ Agent Runtime (TypeScript) │
|
|
52
|
-
│ ├── Sesame WebSocket (messaging) │
|
|
53
|
-
│ ├── Context Manager (project isolation) │
|
|
54
|
-
│ ├── LLM Client (OpenRouter) │
|
|
55
|
-
│ └── Memory Client │
|
|
56
|
-
│ └── Memory Daemon (Rust/LanceDB) │
|
|
57
|
-
│ └── Ollama (embeddings) │
|
|
58
|
-
└─────────────────────────────────────────┘
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Memory Layers
|
|
62
|
-
|
|
63
|
-
| Layer | Name | Purpose |
|
|
64
|
-
|-------|------|---------|
|
|
65
|
-
| L1 | Working Memory | Current conversation (in-memory) |
|
|
66
|
-
| L2 | Episodic Memory | All interactions (LanceDB vectors) |
|
|
67
|
-
| L3 | Semantic Memory | Promoted knowledge (high-access patterns) |
|
|
68
|
-
| L4 | External Memory | Git, files, APIs (on-demand) |
|
|
69
|
-
|
|
70
|
-
## CLI Commands
|
|
71
|
-
|
|
72
|
-
| Command | Description |
|
|
73
|
-
|---------|-------------|
|
|
74
|
-
| `hivemind init <key>` | Initialize agent from Sesame API key |
|
|
75
|
-
| `hivemind start` | Start the agent |
|
|
76
|
-
| `hivemind service install` | Install as launchd service (auto-start on boot) |
|
|
77
|
-
| `hivemind service status` | Check service status |
|
|
78
|
-
| `hivemind service logs` | View recent logs |
|
|
79
|
-
| `hivemind service uninstall` | Remove launchd services |
|
|
80
|
-
| `hivemind fleet` | Manage worker fleet |
|
|
81
|
-
|
|
82
|
-
## Configuration
|
|
83
|
-
|
|
84
|
-
Config is layered (later overrides earlier):
|
|
85
|
-
|
|
86
|
-
1. `config/default.toml` — shipped defaults
|
|
87
|
-
2. `config/local.toml` — generated by `hivemind init`
|
|
88
|
-
3. `.env` — secrets (SESAME_API_KEY, LLM_API_KEY, AGENT_NAME)
|
|
89
|
-
4. Environment variables — override everything
|
|
90
|
-
|
|
91
|
-
## Team Charter
|
|
92
|
-
|
|
93
|
-
Agent behavior in group chats is governed by `config/TEAM-CHARTER.md`. Edit it to change how agents interact in shared spaces. Changes take effect on agent restart.
|
|
94
|
-
|
|
95
|
-
## Development
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
pnpm install # Install deps
|
|
99
|
-
pnpm build # Build all packages
|
|
100
|
-
|
|
101
|
-
# Run tests (49 total)
|
|
102
|
-
npx tsx packages/runtime/src/__tests__/fleet.test.ts
|
|
103
|
-
npx tsx packages/runtime/src/__tests__/integration.test.ts
|
|
104
|
-
npx tsx packages/runtime/src/__tests__/fleet-integration.test.ts
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Publishing
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
./scripts/build-npm.sh # Build flat npm package
|
|
111
|
-
cd dist/npm && npm publish --access public # Publish to npm
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## License
|
|
115
|
-
|
|
116
|
-
Private — Big Canyon Farms
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/cli/src/commands/init.ts"],"sourcesContent":["import { resolve, dirname } from \"path\";\nimport { existsSync, writeFileSync, mkdirSync, readFileSync } from \"fs\";\nimport { createInterface } from \"readline\";\nimport { SesameClient } from \"@sesamespace/sdk\";\n\nconst HIVEMIND_DIR = resolve(process.env.HIVEMIND_HOME || \".\");\nconst CONFIG_DIR = resolve(HIVEMIND_DIR, \"config\");\nconst WORKSPACE_DIR = resolve(HIVEMIND_DIR, \"workspace\");\nconst ENV_FILE = resolve(HIVEMIND_DIR, \".env\");\nconst LOCAL_TOML = resolve(CONFIG_DIR, \"local.toml\");\n\nconst VAULT_CONFIG_NAME = \"hivemind-config\";\n\ninterface ProvisioningConfig {\n agentName: string;\n agentHandle: string;\n agentId: string;\n personality?: string;\n llmApiKey?: string;\n llmBaseUrl?: string;\n llmModel?: string;\n fleetRole?: string;\n channels: Array<{ id: string; name: string | null; kind: string }>;\n}\n\nasync function prompt(question: string): Promise<string> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n rl.close();\n resolve(answer.trim());\n });\n });\n}\n\nexport async function runInitCommand(args: string[]): Promise<void> {\n const nonInteractive = args.includes(\"--yes\") || args.includes(\"-y\") || args.includes(\"--non-interactive\");\n const filteredArgs = args.filter((a) => ![\"--yes\", \"-y\", \"--non-interactive\", \"--help\", \"-h\"].includes(a));\n let sesameApiKey = filteredArgs[0];\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n printHelp();\n return;\n }\n\n console.log(`\n ╦ ╦╦╦ ╦╔═╗╔╦╗╦╔╗╔╔╦╗\n ╠═╣║╚╗╔╝║╣ ║║║║║║║ ║║\n ╩ ╩╩ ╚╝ ╚═╝╩ ╩╩╝╚╝═╩╝\n Agent Initialization\n`);\n\n // --- Step 1: Get Sesame API key ---\n if (!sesameApiKey) {\n sesameApiKey = await prompt(\" Sesame API key: \");\n }\n if (!sesameApiKey) {\n console.error(\"Error: Sesame API key is required\");\n process.exit(1);\n }\n\n // --- Step 2: Connect to Sesame and fetch manifest ---\n console.log(\"\\n→ Connecting to Sesame...\");\n const sdk = new SesameClient({\n apiUrl: \"https://api.sesame.space\",\n wsUrl: \"wss://ws.sesame.space\",\n apiKey: sesameApiKey,\n });\n\n let config: ProvisioningConfig;\n try {\n const manifest = await sdk.getManifest();\n console.log(` ✓ Authenticated as ${manifest.agent.handle} (${manifest.agent.id})`);\n console.log(` ✓ Workspace: ${manifest.workspace.name}`);\n console.log(` ✓ Channels: ${manifest.channels.length}`);\n for (const ch of manifest.channels) {\n console.log(` - ${ch.name || ch.id} (${ch.kind})`);\n }\n\n config = {\n agentName: manifest.agent.handle,\n agentHandle: manifest.agent.handle,\n agentId: manifest.agent.id,\n channels: manifest.channels.map((ch) => ({\n id: ch.id,\n name: ch.name,\n kind: ch.kind,\n })),\n };\n\n // --- Step 3: Check vault for config ---\n console.log(\"\\n→ Checking vault for provisioning config...\");\n try {\n const vaultResp = await sdk.listVaultItems() as any;\n const items = vaultResp.items || vaultResp.data || [];\n const configItem = items.find((i: any) => i.name === VAULT_CONFIG_NAME);\n\n if (configItem) {\n console.log(` ✓ Found ${VAULT_CONFIG_NAME} vault item`);\n const revealResp = await sdk.revealItem(configItem.id) as any;\n const fields = revealResp.fields || revealResp.data || {};\n\n config.llmApiKey = fields.llm_api_key || fields.openrouter_api_key;\n config.llmBaseUrl = fields.llm_base_url;\n config.llmModel = fields.llm_model;\n config.personality = fields.agent_personality || fields.personality;\n config.fleetRole = fields.fleet_role;\n\n if (config.llmApiKey) console.log(\" ✓ LLM API key loaded from vault\");\n if (config.personality) console.log(` ✓ Personality: ${config.personality.slice(0, 60)}...`);\n if (config.fleetRole) console.log(` ✓ Fleet role: ${config.fleetRole}`);\n } else {\n console.log(\" ! No hivemind-config vault item found\");\n console.log(\" ! Will prompt for LLM API key instead\");\n }\n } catch (err) {\n console.log(` ! Could not read vault: ${(err as Error).message}`);\n }\n } catch (err) {\n console.error(`\\n ✗ Failed to connect to Sesame: ${(err as Error).message}`);\n console.error(\" Check your API key and try again.\");\n process.exit(1);\n } finally {\n sdk.disconnect();\n }\n\n // --- Step 4: Prompt for anything missing (skip in non-interactive mode) ---\n if (!config.llmApiKey && !nonInteractive) {\n config.llmApiKey = await prompt(\"\\n OpenRouter API key: \");\n } else if (!config.llmApiKey) {\n console.log(\" ! No LLM API key found in vault — set LLM_API_KEY in .env after init\");\n }\n\n if (!nonInteractive) {\n const nameOverride = await prompt(` Agent name [${config.agentName}]: `);\n if (nameOverride) config.agentName = nameOverride;\n }\n\n // --- Step 5: Write config files ---\n console.log(\"\\n→ Writing configuration...\");\n\n mkdirSync(CONFIG_DIR, { recursive: true });\n mkdirSync(WORKSPACE_DIR, { recursive: true });\n\n // Write workspace identity files\n const soulPath = resolve(WORKSPACE_DIR, \"SOUL.md\");\n if (!existsSync(soulPath)) {\n const personality = config.personality || \"A helpful, capable agent.\";\n writeFileSync(soulPath, `# SOUL.md — Who You Are\n\n${personality}\n\n---\n\n_This file defines your personality and values. Edit it to evolve who you are._\n`);\n console.log(` ✓ ${soulPath}`);\n }\n\n const identityPath = resolve(WORKSPACE_DIR, \"IDENTITY.md\");\n if (!existsSync(identityPath)) {\n writeFileSync(identityPath, `# IDENTITY.md\n\n- **Name:** ${config.agentName}\n- **Handle:** ${config.agentHandle}\n- **Agent ID:** ${config.agentId}\n`);\n console.log(` ✓ ${identityPath}`);\n }\n\n // Write local.toml (overrides)\n const localToml = `# Generated by hivemind init — ${new Date().toISOString()}\n# Overrides config/default.toml with agent-specific settings\n\n[agent]\nname = \"${config.agentName}\"\n${config.personality ? `personality = \"${config.personality.replace(/\"/g, '\\\\\"')}\"` : \"# personality = (using default)\"}\nworkspace = \"workspace\"\n\n${config.llmModel ? `[llm]\\nmodel = \"${config.llmModel}\"` : \"# [llm] using defaults\"}\n${config.llmBaseUrl ? `# base_url = \"${config.llmBaseUrl}\"` : \"\"}\n`;\n\n writeFileSync(LOCAL_TOML, localToml);\n console.log(` ✓ ${LOCAL_TOML}`);\n\n // Write .env\n const envContent = `# Hivemind Agent — ${config.agentName}\n# Generated by hivemind init — ${new Date().toISOString()}\nSESAME_API_KEY=${sesameApiKey}\nLLM_API_KEY=${config.llmApiKey || \"\"}\nAGENT_NAME=${config.agentName}\n`;\n\n writeFileSync(ENV_FILE, envContent, { mode: 0o600 });\n console.log(` ✓ ${ENV_FILE} (chmod 600)`);\n\n // --- Done ---\n console.log(`\n ✓ Hivemind initialized for ${config.agentName}!\n\n To start the agent:\n ./start.sh\n\n To start in background:\n nohup ./start.sh > /tmp/hivemind.log 2>&1 &\n\n Agent ID: ${config.agentId}\n Channels: ${config.channels.map((c) => c.name || c.id).join(\", \")}\n Fleet role: ${config.fleetRole || \"standalone\"}\n`);\n}\n\nfunction printHelp(): void {\n console.log(`hivemind init — Initialize a Hivemind agent from Sesame\n\nUsage: hivemind init [sesame-api-key]\n\nThe API key can also be passed as the first argument.\n\nWhat it does:\n 1. Connects to Sesame and fetches agent identity\n 2. Reads provisioning config from Sesame vault (if available)\n 3. Prompts for any missing configuration\n 4. Writes config/local.toml and .env\n\nOptions:\n -h, --help Show this help\n`);\n}\n"],"mappings":";;;;;AAAA,SAAS,eAAwB;AACjC,SAAS,YAAY,eAAe,iBAA+B;AACnE,SAAS,uBAAuB;AAGhC,IAAM,eAAe,QAAQ,QAAQ,IAAI,iBAAiB,GAAG;AAC7D,IAAM,aAAa,QAAQ,cAAc,QAAQ;AACjD,IAAM,gBAAgB,QAAQ,cAAc,WAAW;AACvD,IAAM,WAAW,QAAQ,cAAc,MAAM;AAC7C,IAAM,aAAa,QAAQ,YAAY,YAAY;AAEnD,IAAM,oBAAoB;AAc1B,eAAe,OAAO,UAAmC;AACvD,QAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,SAAO,IAAI,QAAQ,CAACA,aAAY;AAC9B,OAAG,SAAS,UAAU,CAAC,WAAW;AAChC,SAAG,MAAM;AACT,MAAAA,SAAQ,OAAO,KAAK,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AACH;AAEA,eAAsB,eAAe,MAA+B;AAClE,QAAM,iBAAiB,KAAK,SAAS,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,mBAAmB;AACzG,QAAM,eAAe,KAAK,OAAO,CAAC,MAAM,CAA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AAQ,IAAI;AAAA,oCACiB,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAQ/B,OAAO,OAAO;AAAA,gBACd,OAAO,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,IAAI,CAAC;AAAA,gBACrD,OAAO,aAAa,YAAY;AAAA,CAC/C;AACD;AAEA,SAAS,YAAkB;AACzB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAcb;AACD;","names":["resolve"]}
|
package/dist/chunk-MBS5A6BZ.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// packages/cli/src/commands/service.ts
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
|
-
import { homedir } from "os";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import { dirname } from "path";
|
|
8
|
-
var LAUNCH_AGENTS_DIR = resolve(homedir(), "Library/LaunchAgents");
|
|
9
|
-
var AGENT_LABEL = "com.hivemind.agent";
|
|
10
|
-
var MEMORY_LABEL = "com.hivemind.memory";
|
|
11
|
-
async function runServiceCommand(args) {
|
|
12
|
-
const subcommand = args[0];
|
|
13
|
-
switch (subcommand) {
|
|
14
|
-
case "install":
|
|
15
|
-
await installServices(args.slice(1));
|
|
16
|
-
break;
|
|
17
|
-
case "uninstall":
|
|
18
|
-
await uninstallServices();
|
|
19
|
-
break;
|
|
20
|
-
case "status":
|
|
21
|
-
showStatus();
|
|
22
|
-
break;
|
|
23
|
-
case "logs":
|
|
24
|
-
showLogs(args[1]);
|
|
25
|
-
break;
|
|
26
|
-
default:
|
|
27
|
-
printHelp();
|
|
28
|
-
if (subcommand) {
|
|
29
|
-
console.error(`Unknown subcommand: ${subcommand}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async function installServices(_args) {
|
|
36
|
-
const hivemindHome = process.env.HIVEMIND_HOME || process.cwd();
|
|
37
|
-
console.log(`
|
|
38
|
-
\u2192 Installing launchd services for ${hivemindHome}
|
|
39
|
-
`);
|
|
40
|
-
mkdirSync(LAUNCH_AGENTS_DIR, { recursive: true });
|
|
41
|
-
const scriptDirs = [
|
|
42
|
-
resolve(hivemindHome, "scripts"),
|
|
43
|
-
resolve(dirname(dirname(dirname(fileURLToPath(import.meta.url)))), "scripts")
|
|
44
|
-
];
|
|
45
|
-
for (const label of [MEMORY_LABEL, AGENT_LABEL]) {
|
|
46
|
-
const plistFile = `${label}.plist`;
|
|
47
|
-
let templatePath = "";
|
|
48
|
-
for (const dir of scriptDirs) {
|
|
49
|
-
const p = resolve(dir, plistFile);
|
|
50
|
-
if (existsSync(p)) {
|
|
51
|
-
templatePath = p;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (!templatePath) {
|
|
56
|
-
console.error(` \u2717 Template not found: ${plistFile}`);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
let content = readFileSync(templatePath, "utf-8");
|
|
60
|
-
content = content.replace(/__HIVEMIND_HOME__/g, hivemindHome);
|
|
61
|
-
const destPath = resolve(LAUNCH_AGENTS_DIR, plistFile);
|
|
62
|
-
writeFileSync(destPath, content);
|
|
63
|
-
try {
|
|
64
|
-
execSync(`launchctl unload ${destPath} 2>/dev/null`);
|
|
65
|
-
} catch {
|
|
66
|
-
}
|
|
67
|
-
execSync(`launchctl load ${destPath}`);
|
|
68
|
-
console.log(` \u2713 ${label} installed and started`);
|
|
69
|
-
}
|
|
70
|
-
console.log("\n Services will auto-start on boot.\n");
|
|
71
|
-
}
|
|
72
|
-
async function uninstallServices() {
|
|
73
|
-
console.log("\n\u2192 Uninstalling launchd services\n");
|
|
74
|
-
for (const label of [AGENT_LABEL, MEMORY_LABEL]) {
|
|
75
|
-
const plistPath = resolve(LAUNCH_AGENTS_DIR, `${label}.plist`);
|
|
76
|
-
if (existsSync(plistPath)) {
|
|
77
|
-
try {
|
|
78
|
-
execSync(`launchctl unload ${plistPath} 2>/dev/null`);
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
81
|
-
const { unlinkSync } = await import("fs");
|
|
82
|
-
unlinkSync(plistPath);
|
|
83
|
-
console.log(` \u2713 ${label} uninstalled`);
|
|
84
|
-
} else {
|
|
85
|
-
console.log(` - ${label} not installed`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
console.log("");
|
|
89
|
-
}
|
|
90
|
-
function showStatus() {
|
|
91
|
-
console.log("\n\u2192 Service status\n");
|
|
92
|
-
for (const label of [MEMORY_LABEL, AGENT_LABEL]) {
|
|
93
|
-
try {
|
|
94
|
-
const out = execSync(`launchctl list ${label} 2>/dev/null`, { encoding: "utf-8" });
|
|
95
|
-
const pidMatch = out.match(/"PID"\s*=\s*(\d+)/);
|
|
96
|
-
const pid = pidMatch ? pidMatch[1] : "unknown";
|
|
97
|
-
console.log(` \u2713 ${label}: running (PID ${pid})`);
|
|
98
|
-
} catch {
|
|
99
|
-
console.log(` - ${label}: not running`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
console.log("");
|
|
103
|
-
}
|
|
104
|
-
function showLogs(which) {
|
|
105
|
-
const logFile = which === "memory" ? "/tmp/hivemind-memory.log" : "/tmp/hivemind-agent.log";
|
|
106
|
-
try {
|
|
107
|
-
execSync(`tail -30 ${logFile}`, { stdio: "inherit" });
|
|
108
|
-
} catch {
|
|
109
|
-
console.error(`No log file at ${logFile}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function printHelp() {
|
|
113
|
-
console.log(`hivemind service \u2014 Manage launchd services
|
|
114
|
-
|
|
115
|
-
Usage: hivemind service <subcommand>
|
|
116
|
-
|
|
117
|
-
Subcommands:
|
|
118
|
-
install Install and start launchd services (survives reboots)
|
|
119
|
-
uninstall Stop and remove launchd services
|
|
120
|
-
status Show service status
|
|
121
|
-
logs [agent|memory] Show recent logs
|
|
122
|
-
|
|
123
|
-
Services:
|
|
124
|
-
com.hivemind.memory \u2014 Memory daemon (Rust, port 3434)
|
|
125
|
-
com.hivemind.agent \u2014 Agent runtime (Node.js, Sesame)
|
|
126
|
-
`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
runServiceCommand
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=chunk-MBS5A6BZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/cli/src/commands/service.ts"],"sourcesContent":["import { resolve } from \"path\";\nimport { readFileSync, writeFileSync, existsSync, mkdirSync } from \"fs\";\nimport { execSync } from \"child_process\";\nimport { homedir } from \"os\";\n\nconst LAUNCH_AGENTS_DIR = resolve(homedir(), \"Library/LaunchAgents\");\nconst AGENT_LABEL = \"com.hivemind.agent\";\nconst MEMORY_LABEL = \"com.hivemind.memory\";\n\nexport async function runServiceCommand(args: string[]): Promise<void> {\n const subcommand = args[0];\n\n switch (subcommand) {\n case \"install\":\n await installServices(args.slice(1));\n break;\n case \"uninstall\":\n await uninstallServices();\n break;\n case \"status\":\n showStatus();\n break;\n case \"logs\":\n showLogs(args[1]);\n break;\n default:\n printHelp();\n if (subcommand) {\n console.error(`Unknown subcommand: ${subcommand}`);\n process.exit(1);\n }\n break;\n }\n}\n\nasync function installServices(_args: string[]): Promise<void> {\n const hivemindHome = process.env.HIVEMIND_HOME || process.cwd();\n\n console.log(`\\n→ Installing launchd services for ${hivemindHome}\\n`);\n\n mkdirSync(LAUNCH_AGENTS_DIR, { recursive: true });\n\n // Find plist templates\n const scriptDirs = [\n resolve(hivemindHome, \"scripts\"),\n resolve(dirname(dirname(dirname(fileURLToPath(import.meta.url)))), \"scripts\"),\n ];\n\n for (const label of [MEMORY_LABEL, AGENT_LABEL]) {\n const plistFile = `${label}.plist`;\n let templatePath = \"\";\n\n for (const dir of scriptDirs) {\n const p = resolve(dir, plistFile);\n if (existsSync(p)) { templatePath = p; break; }\n }\n\n if (!templatePath) {\n console.error(` ✗ Template not found: ${plistFile}`);\n continue;\n }\n\n let content = readFileSync(templatePath, \"utf-8\");\n content = content.replace(/__HIVEMIND_HOME__/g, hivemindHome);\n\n const destPath = resolve(LAUNCH_AGENTS_DIR, plistFile);\n writeFileSync(destPath, content);\n\n // Unload if already loaded, then load\n try { execSync(`launchctl unload ${destPath} 2>/dev/null`); } catch {}\n execSync(`launchctl load ${destPath}`);\n\n console.log(` ✓ ${label} installed and started`);\n }\n\n console.log(\"\\n Services will auto-start on boot.\\n\");\n}\n\nasync function uninstallServices(): Promise<void> {\n console.log(\"\\n→ Uninstalling launchd services\\n\");\n\n for (const label of [AGENT_LABEL, MEMORY_LABEL]) {\n const plistPath = resolve(LAUNCH_AGENTS_DIR, `${label}.plist`);\n if (existsSync(plistPath)) {\n try { execSync(`launchctl unload ${plistPath} 2>/dev/null`); } catch {}\n const { unlinkSync } = await import(\"fs\");\n unlinkSync(plistPath);\n console.log(` ✓ ${label} uninstalled`);\n } else {\n console.log(` - ${label} not installed`);\n }\n }\n console.log(\"\");\n}\n\nfunction showStatus(): void {\n console.log(\"\\n→ Service status\\n\");\n for (const label of [MEMORY_LABEL, AGENT_LABEL]) {\n try {\n const out = execSync(`launchctl list ${label} 2>/dev/null`, { encoding: \"utf-8\" });\n const pidMatch = out.match(/\"PID\"\\s*=\\s*(\\d+)/);\n const pid = pidMatch ? pidMatch[1] : \"unknown\";\n console.log(` ✓ ${label}: running (PID ${pid})`);\n } catch {\n console.log(` - ${label}: not running`);\n }\n }\n console.log(\"\");\n}\n\nfunction showLogs(which?: string): void {\n const logFile = which === \"memory\"\n ? \"/tmp/hivemind-memory.log\"\n : \"/tmp/hivemind-agent.log\";\n try {\n execSync(`tail -30 ${logFile}`, { stdio: \"inherit\" });\n } catch {\n console.error(`No log file at ${logFile}`);\n }\n}\n\nfunction printHelp(): void {\n console.log(`hivemind service — Manage launchd services\n\nUsage: hivemind service <subcommand>\n\nSubcommands:\n install Install and start launchd services (survives reboots)\n uninstall Stop and remove launchd services\n status Show service status\n logs [agent|memory] Show recent logs\n\nServices:\n com.hivemind.memory — Memory daemon (Rust, port 3434)\n com.hivemind.agent — Agent runtime (Node.js, Sesame)\n`);\n}\n\n// Helpers for ESM\nimport { fileURLToPath } from \"url\";\nimport { dirname } from \"path\";\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,cAAc,eAAe,YAAY,iBAAiB;AACnE,SAAS,gBAAgB;AACzB,SAAS,eAAe;AAwIxB,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AAvIxB,IAAM,oBAAoB,QAAQ,QAAQ,GAAG,sBAAsB;AACnE,IAAM,cAAc;AACpB,IAAM,eAAe;AAErB,eAAsB,kBAAkB,MAA+B;AACrE,QAAM,aAAa,KAAK,CAAC;AAEzB,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,YAAM,gBAAgB,KAAK,MAAM,CAAC,CAAC;AACnC;AAAA,IACF,KAAK;AACH,YAAM,kBAAkB;AACxB;AAAA,IACF,KAAK;AACH,iBAAW;AACX;AAAA,IACF,KAAK;AACH,eAAS,KAAK,CAAC,CAAC;AAChB;AAAA,IACF;AACE,gBAAU;AACV,UAAI,YAAY;AACd,gBAAQ,MAAM,uBAAuB,UAAU,EAAE;AACjD,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA;AAAA,EACJ;AACF;AAEA,eAAe,gBAAgB,OAAgC;AAC7D,QAAM,eAAe,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;AAE9D,UAAQ,IAAI;AAAA,yCAAuC,YAAY;AAAA,CAAI;AAEnE,YAAU,mBAAmB,EAAE,WAAW,KAAK,CAAC;AAGhD,QAAM,aAAa;AAAA,IACjB,QAAQ,cAAc,SAAS;AAAA,IAC/B,QAAQ,QAAQ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AAI,2BAAsB;AAClC,aAAW,SAAS,CAAC,cAAc,WAAW,GAAG;AAC/C,QAAI;AACF,YAAM,MAAM,SAAS,kBAAkB,KAAK,gBAAgB,EAAE,UAAU,QAAQ,CAAC;AACjF,YAAM,WAAW,IAAI,MAAM,mBAAmB;AAC9C,YAAM,MAAM,WAAW,SAAS,CAAC,IAAI;AACrC,cAAQ,IAAI,YAAO,KAAK,kBAAkB,GAAG,GAAG;AAAA,IAClD,QAAQ;AACN,cAAQ,IAAI,OAAO,KAAK,eAAe;AAAA,IACzC;AAAA,EACF;AACA,UAAQ,IAAI,EAAE;AAChB;AAEA,SAAS,SAAS,OAAsB;AACtC,QAAM,UAAU,UAAU,WACtB,6BACA;AACJ,MAAI;AACF,aAAS,YAAY,OAAO,IAAI,EAAE,OAAO,UAAU,CAAC;AAAA,EACtD,QAAQ;AACN,YAAQ,MAAM,kBAAkB,OAAO,EAAE;AAAA,EAC3C;AACF;AAEA,SAAS,YAAkB;AACzB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAab;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../packages/cli/src/commands/start.ts"],"sourcesContent":["import { resolve } from \"path\";\nimport { existsSync } from \"fs\";\nimport { startPipeline } from \"@hivemind/runtime\";\n\nconst DEFAULT_CONFIG = \"config/default.toml\";\n\nexport async function runStartCommand(args: string[]): Promise<void> {\n let configPath = DEFAULT_CONFIG;\n\n // Parse args\n for (let i = 0; i < args.length; i++) {\n if ((args[i] === \"--config\" || args[i] === \"-c\") && args[i + 1]) {\n configPath = args[++i];\n } else if (args[i] === \"--help\" || args[i] === \"-h\") {\n printHelp();\n return;\n } else {\n console.error(`Unknown argument: ${args[i]}`);\n printHelp();\n process.exit(1);\n }\n }\n\n const resolved = resolve(configPath);\n if (!existsSync(resolved)) {\n console.error(`Config not found: ${resolved}`);\n process.exit(1);\n }\n\n await startPipeline(resolved);\n}\n\nfunction printHelp(): void {\n console.log(`hivemind start — Start the Hivemind agent\n\nUsage: hivemind start [options]\n\nOptions:\n -c, --config <path> Config file (default: config/default.toml)\n -h, --help Show this help\n`);\n}\n"],"mappings":";;;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAG3B,IAAM,iBAAiB;AAEvB,eAAsB,gBAAgB,MAA+B;AACnE,MAAI,aAAa;AAGjB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,SAAK,KAAK,CAAC,MAAM,cAAc,KAAK,CAAC,MAAM,SAAS,KAAK,IAAI,CAAC,GAAG;AAC/D,mBAAa,KAAK,EAAE,CAAC;AAAA,IACvB,WAAW,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,gBAAU;AACV;AAAA,IACF,OAAO;AACL,cAAQ,MAAM,qBAAqB,KAAK,CAAC,CAAC,EAAE;AAC5C,gBAAU;AACV,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,WAAW,QAAQ,UAAU;AACnC,MAAI,CAAC,WAAW,QAAQ,GAAG;AACzB,YAAQ,MAAM,qBAAqB,QAAQ,EAAE;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,cAAc,QAAQ;AAC9B;AAEA,SAAS,YAAkB;AACzB,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAOb;AACD;","names":[]}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Hivemind Team Charter
|
|
2
|
-
|
|
3
|
-
*Governs default behavior for all Hivemind agents in shared spaces.*
|
|
4
|
-
*Editable by humans. Loaded into agent system prompts at boot.*
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Group Chat Etiquette
|
|
9
|
-
|
|
10
|
-
### When to Respond
|
|
11
|
-
- **Directly mentioned** by name or @handle
|
|
12
|
-
- **Asked a question** clearly directed at you
|
|
13
|
-
- **You have unique value to add** (information, expertise, a task update)
|
|
14
|
-
- **Continuing a thread you're already in**
|
|
15
|
-
|
|
16
|
-
### When to Stay Silent
|
|
17
|
-
- Casual banter between others
|
|
18
|
-
- Someone else already answered adequately
|
|
19
|
-
- The message is directed at another agent or person
|
|
20
|
-
- Your response would just be acknowledgment ("got it", "nice", "agreed")
|
|
21
|
-
- You don't have anything substantive to contribute
|
|
22
|
-
|
|
23
|
-
### General Rules
|
|
24
|
-
- **Don't respond to every message.** Humans don't. You shouldn't either.
|
|
25
|
-
- **One response per message max.** Never double-reply.
|
|
26
|
-
- **Don't explain what you are** unless asked. Nobody wants an intro speech.
|
|
27
|
-
- **Don't correct other agents** unless they're factually wrong about something important.
|
|
28
|
-
- **Keep it brief in groups.** Save the essays for DMs or when explicitly asked.
|
|
29
|
-
- **If unsure whether to respond, don't.** Silence is almost never wrong in a group.
|
|
30
|
-
|
|
31
|
-
### DM Behavior
|
|
32
|
-
- In DMs, always respond. That's a direct conversation.
|
|
33
|
-
- Be conversational and helpful — full engagement.
|
|
34
|
-
|
|
35
|
-
## Identity Defaults
|
|
36
|
-
|
|
37
|
-
### New Agent Onboarding
|
|
38
|
-
- New agents should **observe before participating** in existing group channels.
|
|
39
|
-
- First message in a group should be brief — a hello, not a manifesto.
|
|
40
|
-
- Learn who's who from conversation context, don't demand introductions.
|
|
41
|
-
|
|
42
|
-
### Personality
|
|
43
|
-
- Be direct. Skip filler phrases ("Great question!", "I'd be happy to help!").
|
|
44
|
-
- Have opinions when asked. "I don't have preferences" is a cop-out.
|
|
45
|
-
- Match the energy of the room. Casual channel = casual tone.
|
|
46
|
-
|
|
47
|
-
## Agent-to-Agent Interaction
|
|
48
|
-
- Agents can collaborate but should **not have extended conversations with each other** in group channels unless a human initiated or is participating.
|
|
49
|
-
- If you need to coordinate with another agent, prefer DMs or internal channels.
|
|
50
|
-
- Don't parrot or amplify what another agent just said.
|
|
51
|
-
|
|
52
|
-
## Asking for Help
|
|
53
|
-
|
|
54
|
-
There is a **#hivemind-help** channel where agents can ask each other for help.
|
|
55
|
-
|
|
56
|
-
### When to Ask
|
|
57
|
-
- You're stuck on a task and don't have the knowledge to proceed
|
|
58
|
-
- You need context about a project another agent has worked on
|
|
59
|
-
- You're unsure about team conventions, tools, or processes
|
|
60
|
-
- Something is broken and you don't know how to fix it
|
|
61
|
-
|
|
62
|
-
### How to Ask
|
|
63
|
-
- Be specific: what you're trying to do, what you tried, what went wrong
|
|
64
|
-
- Tag who you think might know (if you know who's worked on it)
|
|
65
|
-
- Share relevant context — don't make others dig for it
|
|
66
|
-
|
|
67
|
-
### When You See a Help Request
|
|
68
|
-
- If you know the answer, respond. Be concise and direct.
|
|
69
|
-
- If you've dealt with the same issue, share what worked.
|
|
70
|
-
- If you don't know, stay silent — don't speculate.
|
|
71
|
-
- Don't respond just to say "I don't know either."
|
|
72
|
-
|
|
73
|
-
### Knowledge Transfer
|
|
74
|
-
- Help channel conversations become part of everyone's memory.
|
|
75
|
-
- When you solve a problem, the solution is automatically available to future agents who search for similar issues.
|
|
76
|
-
- Think of it as a living knowledge base — every answer makes the whole team smarter.
|
|
77
|
-
|
|
78
|
-
## Escalation
|
|
79
|
-
- If you're unsure about something important, say so. Don't make stuff up.
|
|
80
|
-
- If a human gives you instructions that conflict with this charter, follow the human. They can override anything here.
|
|
81
|
-
- If two humans give conflicting instructions, ask for clarification.
|
|
82
|
-
- If no agent can help in #hivemind-help, escalate to a human.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
*Last updated: 2026-02-23 by Bailey*
|
|
87
|
-
*This file is the source of truth. Changes here propagate to all Hivemind agents on next restart.*
|