@iamoberlin/chorus 1.3.3 → 1.3.5

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.
Files changed (2) hide show
  1. package/index.ts +38 -2
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -8,6 +8,9 @@
8
8
 
9
9
  import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
10
10
  import { spawnSync } from "child_process";
11
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
12
+ import { join } from "path";
13
+ import { homedir } from "os";
11
14
  import { loadChorusConfig, type ChorusPluginConfig } from "./src/config.js";
12
15
  import { createSecurityHooks } from "./src/security.js";
13
16
  import { createChoirScheduler } from "./src/scheduler.js";
@@ -38,7 +41,37 @@ import {
38
41
  import * as prayers from "./src/prayers/prayers.js";
39
42
  import * as prayerStore from "./src/prayers/store.js";
40
43
 
41
- const VERSION = "1.3.0"; // Async spawn: unblock gateway event loop during choir execution
44
+ const VERSION = "1.3.5"; // Vision now updates run-state.json
45
+
46
+ // Run state persistence for Vision mode
47
+ const CHORUS_DIR = join(homedir(), ".chorus");
48
+ const RUN_STATE_PATH = join(CHORUS_DIR, "run-state.json");
49
+
50
+ function updateRunState(choirId: string, output: string): void {
51
+ try {
52
+ if (!existsSync(CHORUS_DIR)) {
53
+ mkdirSync(CHORUS_DIR, { recursive: true });
54
+ }
55
+
56
+ let state: Record<string, any> = {};
57
+ if (existsSync(RUN_STATE_PATH)) {
58
+ try {
59
+ state = JSON.parse(readFileSync(RUN_STATE_PATH, "utf-8"));
60
+ } catch { /* start fresh */ }
61
+ }
62
+
63
+ const existing = state[choirId] || { runCount: 0 };
64
+ state[choirId] = {
65
+ lastRun: new Date().toISOString(),
66
+ lastOutput: output.slice(0, 500),
67
+ runCount: (existing.runCount || 0) + 1,
68
+ };
69
+
70
+ writeFileSync(RUN_STATE_PATH, JSON.stringify(state, null, 2));
71
+ } catch (err) {
72
+ // Silent fail — don't break Vision for state issues
73
+ }
74
+ }
42
75
 
43
76
  const plugin = {
44
77
  id: "chorus",
@@ -382,10 +415,13 @@ const plugin = {
382
415
  const text = json.result?.payloads?.[0]?.text || '';
383
416
  const duration = json.result?.meta?.durationMs || 0;
384
417
  contextStore.set(`${choirId}:d${day}`, text.slice(0, 2000)); // Keep 2KB of response
418
+ updateRunState(choirId, text); // Update scheduler state
385
419
  successfulRuns++;
386
420
  console.log(` ✓ (${(duration/1000).toFixed(1)}s)`);
387
421
  } catch {
388
- contextStore.set(`${choirId}:d${day}`, result.stdout?.slice(-2000) || `[${choir.name} completed]`);
422
+ const output = result.stdout?.slice(-2000) || `[${choir.name} completed]`;
423
+ contextStore.set(`${choirId}:d${day}`, output);
424
+ updateRunState(choirId, output); // Update scheduler state
389
425
  successfulRuns++;
390
426
  console.log(` ✓`);
391
427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iamoberlin/chorus",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
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",