@trevonistrevon/pi-loop 0.1.4 → 0.1.6

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/index.js CHANGED
@@ -65,7 +65,7 @@ export default function (pi) {
65
65
  const widget = new LoopWidget(store, undefined, monitorManager);
66
66
  scheduler = new CronScheduler(store, onLoopFire);
67
67
  widget.setScheduler(scheduler);
68
- triggerSystem = new TriggerSystem(pi, scheduler);
68
+ triggerSystem = new TriggerSystem(pi, scheduler, store);
69
69
  // ── pi-tasks integration ──
70
70
  let tasksAvailable = false;
71
71
  const _PROTOCOL_VERSION = 1;
@@ -142,7 +142,7 @@ export default function (pi) {
142
142
  widget.setStore(store);
143
143
  scheduler = new CronScheduler(store, onLoopFire);
144
144
  widget.setScheduler(scheduler);
145
- triggerSystem = new TriggerSystem(pi, scheduler);
145
+ triggerSystem = new TriggerSystem(pi, scheduler, store);
146
146
  }
147
147
  storeUpgraded = true;
148
148
  }
@@ -1,13 +1,15 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import type { CronScheduler } from "./scheduler.js";
3
+ import type { LoopStore } from "./store.js";
3
4
  import type { LoopEntry } from "./types.js";
4
5
  export declare class TriggerSystem {
5
6
  private pi;
6
7
  private scheduler;
8
+ private store;
7
9
  private eventSubscriptions;
8
10
  private hybridTimers;
9
11
  private lastFireTime;
10
- constructor(pi: ExtensionAPI, scheduler: CronScheduler);
12
+ constructor(pi: ExtensionAPI, scheduler: CronScheduler, store: LoopStore);
11
13
  start(): void;
12
14
  stop(): void;
13
15
  add(entry: LoopEntry): void;
@@ -1,12 +1,14 @@
1
1
  export class TriggerSystem {
2
2
  pi;
3
3
  scheduler;
4
+ store;
4
5
  eventSubscriptions = new Map();
5
6
  hybridTimers = new Map();
6
7
  lastFireTime = new Map();
7
- constructor(pi, scheduler) {
8
+ constructor(pi, scheduler, store) {
8
9
  this.pi = pi;
9
10
  this.scheduler = scheduler;
11
+ this.store = store;
10
12
  }
11
13
  start() {
12
14
  this.scheduler.start();
@@ -94,6 +96,10 @@ export class TriggerSystem {
94
96
  trigger: entry.trigger,
95
97
  timestamp: Date.now(),
96
98
  });
99
+ if (!entry.recurring) {
100
+ this.remove(entry.id);
101
+ this.store.update(entry.id, { status: "expired" });
102
+ }
97
103
  }
98
104
  matchesFilter(data, filter) {
99
105
  if (!filter)
package/dist/ui/widget.js CHANGED
@@ -85,7 +85,8 @@ export class LoopWidget {
85
85
  for (const m of monitors.slice(0, Math.max(0, MAX_VISIBLE - loops.length))) {
86
86
  const icon = "◉";
87
87
  const age = Date.now() - m.startedAt;
88
- lines.push(trunc(` ${icon} #${m.id} ${m.command.slice(0, 40)} ${m.outputLines} lines (${formatDuration(age)})`));
88
+ const label = m.description || m.command.replace(/\n/g, " ").replace(/\s+/g, " ").trim().slice(0, 50);
89
+ lines.push(trunc(` ${icon} #${m.id} ${label} ${m.outputLines} lines (${formatDuration(age)})`));
89
90
  }
90
91
  return lines;
91
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trevonistrevon/pi-loop",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "A pi extension for cron/event-based agent re-wake loops and background process monitoring.",
5
5
  "author": "trevonistrevon",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -69,7 +69,7 @@ export default function (pi: ExtensionAPI) {
69
69
 
70
70
  scheduler = new CronScheduler(store, onLoopFire);
71
71
  widget.setScheduler(scheduler);
72
- triggerSystem = new TriggerSystem(pi, scheduler);
72
+ triggerSystem = new TriggerSystem(pi, scheduler, store);
73
73
 
74
74
  // ── pi-tasks integration ──
75
75
  let tasksAvailable = false;
@@ -148,7 +148,7 @@ export default function (pi: ExtensionAPI) {
148
148
  widget.setStore(store);
149
149
  scheduler = new CronScheduler(store, onLoopFire);
150
150
  widget.setScheduler(scheduler);
151
- triggerSystem = new TriggerSystem(pi, scheduler);
151
+ triggerSystem = new TriggerSystem(pi, scheduler, store);
152
152
  }
153
153
  storeUpgraded = true;
154
154
  }
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import type { CronScheduler } from "./scheduler.js";
3
+ import type { LoopStore } from "./store.js";
3
4
  import type { LoopEntry } from "./types.js";
4
5
 
5
6
  export class TriggerSystem {
@@ -10,6 +11,7 @@ export class TriggerSystem {
10
11
  constructor(
11
12
  private pi: ExtensionAPI,
12
13
  private scheduler: CronScheduler,
14
+ private store: LoopStore,
13
15
  ) {}
14
16
 
15
17
  start(): void {
@@ -99,6 +101,11 @@ export class TriggerSystem {
99
101
  trigger: entry.trigger,
100
102
  timestamp: Date.now(),
101
103
  });
104
+
105
+ if (!entry.recurring) {
106
+ this.remove(entry.id);
107
+ this.store.update(entry.id, { status: "expired" });
108
+ }
102
109
  }
103
110
 
104
111
  private matchesFilter(data: any, filter?: string): boolean {
package/src/ui/widget.ts CHANGED
@@ -106,7 +106,8 @@ export class LoopWidget {
106
106
  for (const m of monitors.slice(0, Math.max(0, MAX_VISIBLE - loops.length))) {
107
107
  const icon = "◉";
108
108
  const age = Date.now() - m.startedAt;
109
- lines.push(trunc(` ${icon} #${m.id} ${m.command.slice(0, 40)} ${m.outputLines} lines (${formatDuration(age)})`));
109
+ const label = m.description || m.command.replace(/\n/g, " ").replace(/\s+/g, " ").trim().slice(0, 50);
110
+ lines.push(trunc(` ${icon} #${m.id} ${label} ${m.outputLines} lines (${formatDuration(age)})`));
110
111
  }
111
112
 
112
113
  return lines;