@trevonistrevon/pi-loop 0.2.2 → 0.2.4
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 +2 -18
- package/package.json +1 -1
- package/src/index.ts +2 -21
package/dist/index.js
CHANGED
|
@@ -181,9 +181,7 @@ export default function (pi) {
|
|
|
181
181
|
upgradeStoreIfNeeded(ctx);
|
|
182
182
|
showPersistedLoops(isResume);
|
|
183
183
|
});
|
|
184
|
-
// ──
|
|
185
|
-
let canInjectReminder = true;
|
|
186
|
-
const pendingReminders = [];
|
|
184
|
+
// ── Loop fire handler — sends a user message to re-wake the agent ──
|
|
187
185
|
pi.events.on("loop:fire", (data) => {
|
|
188
186
|
const triggerInfo = typeof data.trigger === "string"
|
|
189
187
|
? data.trigger
|
|
@@ -196,21 +194,7 @@ export default function (pi) {
|
|
|
196
194
|
.replace("%prompt%", data.prompt || "loop fired")
|
|
197
195
|
.replace("%trigger_info%", triggerInfo)
|
|
198
196
|
.replace("%loop_id%", data.loopId || "unknown");
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
// Allow one reminder injection per agent turn (at the first tool call),
|
|
202
|
-
// so the reminder arrives between batches of work, not mid-execution.
|
|
203
|
-
pi.on("turn_start", async () => {
|
|
204
|
-
canInjectReminder = true;
|
|
205
|
-
});
|
|
206
|
-
pi.on("tool_result", async (event) => {
|
|
207
|
-
if (!canInjectReminder || pendingReminders.length === 0)
|
|
208
|
-
return {};
|
|
209
|
-
canInjectReminder = false;
|
|
210
|
-
const reminder = pendingReminders.shift();
|
|
211
|
-
return {
|
|
212
|
-
content: [...event.content, { type: "text", text: reminder }],
|
|
213
|
-
};
|
|
197
|
+
pi.sendUserMessage(reminder);
|
|
214
198
|
});
|
|
215
199
|
// ──────────────────────────────────────────────────
|
|
216
200
|
// Tool 1: LoopCreate
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -193,10 +193,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
193
193
|
showPersistedLoops(isResume);
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
// ──
|
|
197
|
-
|
|
198
|
-
let canInjectReminder = true;
|
|
199
|
-
const pendingReminders: string[] = [];
|
|
196
|
+
// ── Loop fire handler — sends a user message to re-wake the agent ──
|
|
200
197
|
|
|
201
198
|
pi.events.on("loop:fire", (data: any) => {
|
|
202
199
|
const triggerInfo = typeof data.trigger === "string"
|
|
@@ -212,23 +209,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
212
209
|
.replace("%trigger_info%", triggerInfo)
|
|
213
210
|
.replace("%loop_id%", data.loopId || "unknown");
|
|
214
211
|
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
// Allow one reminder injection per agent turn (at the first tool call),
|
|
219
|
-
// so the reminder arrives between batches of work, not mid-execution.
|
|
220
|
-
pi.on("turn_start", async () => {
|
|
221
|
-
canInjectReminder = true;
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
pi.on("tool_result", async (event) => {
|
|
225
|
-
if (!canInjectReminder || pendingReminders.length === 0) return {};
|
|
226
|
-
|
|
227
|
-
canInjectReminder = false;
|
|
228
|
-
const reminder = pendingReminders.shift()!;
|
|
229
|
-
return {
|
|
230
|
-
content: [...event.content, { type: "text" as const, text: reminder }],
|
|
231
|
-
};
|
|
212
|
+
pi.sendUserMessage(reminder);
|
|
232
213
|
});
|
|
233
214
|
|
|
234
215
|
// ──────────────────────────────────────────────────
|