@iamoberlin/chorus 1.2.8 → 1.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/index.ts CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  import * as prayers from "./src/prayers/prayers.js";
39
39
  import * as prayerStore from "./src/prayers/store.js";
40
40
 
41
- const VERSION = "1.2.7"; // Fixed JSON parsing: extract JSON from output (plugin logs prefix it)
41
+ const VERSION = "1.3.0"; // Async spawn: unblock gateway event loop during choir execution
42
42
 
43
43
  const plugin = {
44
44
  id: "chorus",
@@ -219,14 +219,14 @@ const plugin = {
219
219
  console.error(` ✗ ${choir.name} failed:`, err);
220
220
  }
221
221
  } else {
222
- // CLI context: use openclaw agent with --message flag
222
+ // CLI context: use openclaw agent with stdin
223
223
  try {
224
224
  const result = spawnSync('openclaw', [
225
225
  'agent',
226
226
  '--session-id', `chorus:${id}`,
227
- '--message', choir.prompt,
228
227
  '--json',
229
228
  ], {
229
+ input: choir.prompt,
230
230
  encoding: 'utf-8',
231
231
  timeout: 300000, // 5 min
232
232
  maxBuffer: 1024 * 1024, // 1MB
@@ -328,9 +328,9 @@ const plugin = {
328
328
  const result = spawnSync('openclaw', [
329
329
  'agent',
330
330
  '--session-id', `chorus:vision:dry:${choirId}:d${day}`,
331
- '--message', dryPrompt,
332
331
  '--json',
333
332
  ], {
333
+ input: dryPrompt,
334
334
  encoding: 'utf-8',
335
335
  timeout: 60000,
336
336
  maxBuffer: 1024 * 1024,
@@ -364,9 +364,9 @@ const plugin = {
364
364
  const result = spawnSync('openclaw', [
365
365
  'agent',
366
366
  '--session-id', `chorus:vision:${choirId}:d${day}`,
367
- '--message', choir.prompt,
368
367
  '--json',
369
368
  ], {
369
+ input: choir.prompt,
370
370
  encoding: 'utf-8',
371
371
  timeout: 300000, // 5 min timeout per choir (real work takes longer)
372
372
  maxBuffer: 10 * 1024 * 1024, // 10MB buffer for full output
@@ -2,7 +2,7 @@
2
2
  "id": "chorus",
3
3
  "name": "CHORUS",
4
4
  "description": "CHORUS: Hierarchy Of Recursive Unified Self-improvement",
5
- "version": "1.1.3",
5
+ "version": "1.3.0",
6
6
  "author": "Oberlin",
7
7
  "homepage": "https://chorus.oberlin.ai",
8
8
  "repository": "https://github.com/iamoberlin/chorus",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamoberlin/chorus",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "description": "CHORUS: Hierarchy Of Recursive Unified Self-improvement — with Prayer Requests social network",
5
5
  "author": "Oberlin <iam@oberlin.ai>",
6
6
  "license": "MIT",
package/src/choirs.ts CHANGED
@@ -30,7 +30,7 @@ export const CHOIRS: Record<string, Choir> = {
30
30
  seraphim: {
31
31
  id: "seraphim",
32
32
  name: "Seraphim",
33
- emoji: "",
33
+ emoji: "🔥",
34
34
  triad: "contemplation",
35
35
  frequencyPerDay: 1, // 1×/day
36
36
  intervalMinutes: 1440, // Once per day
@@ -59,7 +59,7 @@ Pass illumination to Cherubim.`,
59
59
  cherubim: {
60
60
  id: "cherubim",
61
61
  name: "Cherubim",
62
- emoji: "",
62
+ emoji: "📚",
63
63
  triad: "contemplation",
64
64
  frequencyPerDay: 2, // 2×/day
65
65
  intervalMinutes: 720, // Every 12 hours
@@ -96,7 +96,7 @@ Pass illumination to Thrones.`,
96
96
  thrones: {
97
97
  id: "thrones",
98
98
  name: "Thrones",
99
- emoji: "",
99
+ emoji: "⚖️",
100
100
  triad: "contemplation",
101
101
  frequencyPerDay: 3, // 3×/day
102
102
  intervalMinutes: 480, // Every 8 hours
@@ -131,7 +131,7 @@ Pass illumination to Dominions.`,
131
131
  dominions: {
132
132
  id: "dominions",
133
133
  name: "Dominions",
134
- emoji: "",
134
+ emoji: "👑",
135
135
  triad: "governance",
136
136
  frequencyPerDay: 4, // 4×/day
137
137
  intervalMinutes: 360, // Every 6 hours
@@ -161,7 +161,7 @@ Pass illumination to Virtues.`,
161
161
  virtues: {
162
162
  id: "virtues",
163
163
  name: "Virtues",
164
- emoji: "",
164
+ emoji: "🔧",
165
165
  triad: "governance",
166
166
  frequencyPerDay: 6, // 6×/day — THE RSI ENGINE
167
167
  intervalMinutes: 240, // Every 4 hours
@@ -211,7 +211,7 @@ Pass illumination to Powers.`,
211
211
  powers: {
212
212
  id: "powers",
213
213
  name: "Powers",
214
- emoji: "",
214
+ emoji: "🛡️",
215
215
  triad: "governance",
216
216
  frequencyPerDay: 8, // 8×/day
217
217
  intervalMinutes: 180, // Every 3 hours
@@ -262,7 +262,7 @@ If thesis is seriously threatened or security issue found: ALERT immediately.`,
262
262
  principalities: {
263
263
  id: "principalities",
264
264
  name: "Principalities",
265
- emoji: "",
265
+ emoji: "🔭",
266
266
  triad: "action",
267
267
  frequencyPerDay: 12, // 12×/day
268
268
  intervalMinutes: 120, // Every 2 hours
@@ -304,7 +304,7 @@ Pass illumination to Archangels.`,
304
304
  archangels: {
305
305
  id: "archangels",
306
306
  name: "Archangels",
307
- emoji: "",
307
+ emoji: "📢",
308
308
  triad: "action",
309
309
  frequencyPerDay: 18, // 18×/day
310
310
  intervalMinutes: 80, // Every ~80 minutes
@@ -340,7 +340,7 @@ Output: Briefing or alert message to deliver.`,
340
340
  angels: {
341
341
  id: "angels",
342
342
  name: "Angels",
343
- emoji: "",
343
+ emoji: "💫",
344
344
  triad: "action",
345
345
  frequencyPerDay: 48, // 48×/day — continuous presence
346
346
  intervalMinutes: 30, // Every 30 minutes
@@ -11,7 +11,7 @@ import { recordExecution, type ChoirExecution } from "./metrics.js";
11
11
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
12
12
  import { join } from "path";
13
13
  import { homedir } from "os";
14
- import { spawnSync } from "child_process";
14
+ import { spawn } from "child_process";
15
15
 
16
16
  // Workspace path for research output
17
17
  const WORKSPACE_PATH = process.env.OPENCLAW_WORKSPACE || join(homedir(), ".openclaw", "workspace");
@@ -274,17 +274,28 @@ CRITICAL: If sending alerts via iMessage, use PLAIN TEXT ONLY (no markdown).
274
274
  }
275
275
 
276
276
  if (!result) {
277
- // CLI fallback - use stdin to avoid arg length limits
277
+ // CLI fallback - use stdin to avoid arg length limits (async to avoid blocking event loop)
278
278
  log.debug(`[purpose-research] Using CLI fallback for "${purpose.name}"`);
279
- result = spawnSync("openclaw", [
280
- "agent",
281
- "--session-id", `chorus:purpose:${purpose.id}`,
282
- "--json",
283
- ], {
284
- input: prompt,
285
- encoding: "utf-8",
286
- timeout: config.researchTimeoutMs,
287
- maxBuffer: 1024 * 1024, // 1MB
279
+ result = await new Promise<any>((resolve) => {
280
+ const child = spawn("openclaw", [
281
+ "agent",
282
+ "--session-id", `chorus:purpose:${purpose.id}`,
283
+ "--json",
284
+ ], { stdio: ['pipe', 'pipe', 'pipe'] });
285
+
286
+ let stdout = '';
287
+ let stderr = '';
288
+ const maxBuffer = 1024 * 1024;
289
+ child.stdout.on('data', (d: Buffer) => { if (stdout.length < maxBuffer) stdout += d.toString(); });
290
+ child.stderr.on('data', (d: Buffer) => { if (stderr.length < maxBuffer) stderr += d.toString(); });
291
+
292
+ // Write prompt to stdin
293
+ child.stdin.write(prompt);
294
+ child.stdin.end();
295
+
296
+ const timer = setTimeout(() => { child.kill('SIGTERM'); }, config.researchTimeoutMs);
297
+ child.on('close', (code) => { clearTimeout(timer); resolve({ status: code, stdout, stderr }); });
298
+ child.on('error', (err) => { clearTimeout(timer); resolve({ status: 1, stdout: '', stderr: String(err) }); });
288
299
  });
289
300
 
290
301
  if (result.status === 0 && result.stdout) {
package/src/scheduler.ts CHANGED
@@ -12,6 +12,7 @@ import { recordExecution, type ChoirExecution } from "./metrics.js";
12
12
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
13
13
  import { join } from "path";
14
14
  import { homedir } from "os";
15
+ import { spawn } from "child_process";
15
16
 
16
17
  interface ChoirContext {
17
18
  choirId: string;
@@ -109,7 +110,7 @@ export function createChoirScheduler(
109
110
  return prompt;
110
111
  }
111
112
 
112
- // Execute a choir
113
+ // Execute a choir using openclaw agent CLI
113
114
  async function executeChoir(choir: Choir): Promise<void> {
114
115
  const state = runState.get(choir.id) || { runCount: 0 };
115
116
  const startTime = Date.now();
@@ -127,19 +128,50 @@ export function createChoirScheduler(
127
128
  try {
128
129
  const prompt = buildPrompt(choir);
129
130
 
130
- // Use OpenClaw's session system to run an agent turn
131
- const result = await api.runAgentTurn?.({
132
- sessionLabel: `chorus:${choir.id}`,
133
- message: prompt,
134
- isolated: true,
135
- timeoutSeconds: 300, // 5 min max
131
+ // Use openclaw agent CLI (async to avoid blocking event loop)
132
+ const result = await new Promise<{ status: number | null; stdout: string; stderr: string }>((resolve) => {
133
+ const child = spawn('openclaw', [
134
+ 'agent',
135
+ '--session-id', `chorus:${choir.id}`,
136
+ '--message', prompt,
137
+ '--json',
138
+ ], { stdio: ['pipe', 'pipe', 'pipe'] });
139
+
140
+ let stdout = '';
141
+ let stderr = '';
142
+ const maxBuffer = 1024 * 1024;
143
+ child.stdout.on('data', (d: Buffer) => { if (stdout.length < maxBuffer) stdout += d.toString(); });
144
+ child.stderr.on('data', (d: Buffer) => { if (stderr.length < maxBuffer) stderr += d.toString(); });
145
+
146
+ const timer = setTimeout(() => { child.kill('SIGTERM'); }, 300000); // 5 min
147
+ child.on('close', (code) => { clearTimeout(timer); resolve({ status: code, stdout, stderr }); });
148
+ child.on('error', (err) => { clearTimeout(timer); resolve({ status: 1, stdout: '', stderr: String(err) }); });
136
149
  });
137
150
 
138
- const output = result?.response || "(no response)";
151
+ let output = "(no response)";
152
+
153
+ if (result.status === 0 && result.stdout) {
154
+ // Extract JSON from output (may have plugin logs before it)
155
+ const stdout = result.stdout;
156
+ const jsonStart = stdout.indexOf('{');
157
+ if (jsonStart >= 0) {
158
+ try {
159
+ const parsed = JSON.parse(stdout.slice(jsonStart));
160
+ output = parsed.response || parsed.content || stdout;
161
+ } catch {
162
+ output = stdout;
163
+ }
164
+ } else {
165
+ output = stdout;
166
+ }
167
+ } else if (result.stderr) {
168
+ log.warn(`[chorus] ${choir.name} stderr: ${result.stderr.slice(0, 200)}`);
169
+ }
170
+
139
171
  execution.durationMs = Date.now() - startTime;
140
- execution.success = true;
172
+ execution.success = result.status === 0;
141
173
  execution.outputLength = output.length;
142
- execution.tokensUsed = result?.meta?.tokensUsed || estimateTokens(output);
174
+ execution.tokensUsed = estimateTokens(output);
143
175
 
144
176
  // Parse output for metrics (findings, alerts, improvements)
145
177
  execution.findings = countFindings(output);