@iamoberlin/chorus 1.2.5 → 1.2.7
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 +27 -12
- package/package.json +1 -1
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.
|
|
41
|
+
const VERSION = "1.2.7"; // Fixed JSON parsing: extract JSON from output (plugin logs prefix it)
|
|
42
42
|
|
|
43
43
|
const plugin = {
|
|
44
44
|
id: "chorus",
|
|
@@ -208,19 +208,25 @@ const plugin = {
|
|
|
208
208
|
isolated: true,
|
|
209
209
|
timeoutSeconds: 300,
|
|
210
210
|
});
|
|
211
|
-
|
|
211
|
+
const text = result?.text || result?.payloads?.[0]?.text || '';
|
|
212
|
+
const duration = result?.meta?.durationMs || 0;
|
|
213
|
+
console.log(` ✓ ${choir.name} complete (${(duration/1000).toFixed(1)}s)`);
|
|
214
|
+
if (text) {
|
|
215
|
+
const preview = text.slice(0, 150).replace(/\n/g, ' ');
|
|
216
|
+
console.log(` ${preview}${text.length > 150 ? '...' : ''}`);
|
|
217
|
+
}
|
|
212
218
|
} catch (err) {
|
|
213
219
|
console.error(` ✗ ${choir.name} failed:`, err);
|
|
214
220
|
}
|
|
215
221
|
} else {
|
|
216
|
-
// CLI context: use openclaw agent
|
|
222
|
+
// CLI context: use openclaw agent with --message flag
|
|
217
223
|
try {
|
|
218
224
|
const result = spawnSync('openclaw', [
|
|
219
225
|
'agent',
|
|
220
226
|
'--session-id', `chorus:${id}`,
|
|
227
|
+
'--message', choir.prompt,
|
|
221
228
|
'--json',
|
|
222
229
|
], {
|
|
223
|
-
input: choir.prompt,
|
|
224
230
|
encoding: 'utf-8',
|
|
225
231
|
timeout: 300000, // 5 min
|
|
226
232
|
maxBuffer: 1024 * 1024, // 1MB
|
|
@@ -228,7 +234,11 @@ const plugin = {
|
|
|
228
234
|
|
|
229
235
|
if (result.status === 0) {
|
|
230
236
|
try {
|
|
231
|
-
|
|
237
|
+
// Extract JSON from output (may have plugin logs before it)
|
|
238
|
+
const stdout = result.stdout || '';
|
|
239
|
+
const jsonStart = stdout.indexOf('{');
|
|
240
|
+
const jsonStr = jsonStart >= 0 ? stdout.slice(jsonStart) : '{}';
|
|
241
|
+
const json = JSON.parse(jsonStr);
|
|
232
242
|
const text = json.result?.payloads?.[0]?.text || '';
|
|
233
243
|
const duration = json.result?.meta?.durationMs || 0;
|
|
234
244
|
console.log(` ✓ ${choir.name} complete (${(duration/1000).toFixed(1)}s)`);
|
|
@@ -236,8 +246,8 @@ const plugin = {
|
|
|
236
246
|
const preview = text.slice(0, 150).replace(/\n/g, ' ');
|
|
237
247
|
console.log(` ${preview}${text.length > 150 ? '...' : ''}`);
|
|
238
248
|
}
|
|
239
|
-
} catch {
|
|
240
|
-
console.log(` ✓ ${choir.name} complete`);
|
|
249
|
+
} catch (parseErr) {
|
|
250
|
+
console.log(` ✓ ${choir.name} complete (parse error: ${parseErr})`);
|
|
241
251
|
}
|
|
242
252
|
} else {
|
|
243
253
|
const errMsg = result.stderr || result.stdout || 'Unknown error';
|
|
@@ -327,7 +337,10 @@ const plugin = {
|
|
|
327
337
|
});
|
|
328
338
|
if (result.status === 0 && result.stdout) {
|
|
329
339
|
try {
|
|
330
|
-
const
|
|
340
|
+
const stdout = result.stdout;
|
|
341
|
+
const jsonStart = stdout.indexOf('{');
|
|
342
|
+
const jsonStr = jsonStart >= 0 ? stdout.slice(jsonStart) : '{}';
|
|
343
|
+
const json = JSON.parse(jsonStr);
|
|
331
344
|
const text = json.result?.payloads?.[0]?.text || '';
|
|
332
345
|
contextStore.set(`${choirId}:d${day}`, text.slice(0, 500));
|
|
333
346
|
console.log(` ✓ (dry)`);
|
|
@@ -348,22 +361,24 @@ const plugin = {
|
|
|
348
361
|
|
|
349
362
|
try {
|
|
350
363
|
// Run the REAL choir with full tool access via direct agent call
|
|
351
|
-
// Pass the choir prompt via stdin to avoid arg length limits
|
|
352
364
|
const result = spawnSync('openclaw', [
|
|
353
365
|
'agent',
|
|
354
366
|
'--session-id', `chorus:vision:${choirId}:d${day}`,
|
|
367
|
+
'--message', choir.prompt,
|
|
355
368
|
'--json',
|
|
356
369
|
], {
|
|
357
|
-
input: choir.prompt, // Pass the full choir prompt via stdin
|
|
358
370
|
encoding: 'utf-8',
|
|
359
371
|
timeout: 300000, // 5 min timeout per choir (real work takes longer)
|
|
360
372
|
maxBuffer: 10 * 1024 * 1024, // 10MB buffer for full output
|
|
361
373
|
});
|
|
362
374
|
|
|
363
375
|
if (result.status === 0) {
|
|
364
|
-
// Parse the agent response
|
|
376
|
+
// Parse the agent response (extract JSON from output)
|
|
365
377
|
try {
|
|
366
|
-
const
|
|
378
|
+
const stdout = result.stdout || '';
|
|
379
|
+
const jsonStart = stdout.indexOf('{');
|
|
380
|
+
const jsonStr = jsonStart >= 0 ? stdout.slice(jsonStart) : '{}';
|
|
381
|
+
const json = JSON.parse(jsonStr);
|
|
367
382
|
const text = json.result?.payloads?.[0]?.text || '';
|
|
368
383
|
const duration = json.result?.meta?.durationMs || 0;
|
|
369
384
|
contextStore.set(`${choirId}:d${day}`, text.slice(0, 2000)); // Keep 2KB of response
|
package/package.json
CHANGED