@trevonistrevon/pi-loop 0.2.2 → 0.2.3
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 +10 -15
- package/package.json +1 -1
- package/src/index.ts +11 -17
package/dist/index.js
CHANGED
|
@@ -167,6 +167,16 @@ export default function (pi) {
|
|
|
167
167
|
widget.setUICtx(ctx.ui);
|
|
168
168
|
upgradeStoreIfNeeded(ctx);
|
|
169
169
|
showPersistedLoops();
|
|
170
|
+
if (pendingReminders.length > 0) {
|
|
171
|
+
const reminder = pendingReminders.shift();
|
|
172
|
+
return {
|
|
173
|
+
message: {
|
|
174
|
+
customType: "pi-loop",
|
|
175
|
+
content: reminder,
|
|
176
|
+
display: false,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
170
180
|
});
|
|
171
181
|
pi.on("session_switch", async (event, ctx) => {
|
|
172
182
|
_latestCtx = ctx;
|
|
@@ -182,7 +192,6 @@ export default function (pi) {
|
|
|
182
192
|
showPersistedLoops(isResume);
|
|
183
193
|
});
|
|
184
194
|
// ── System-reminder injection for loop fires ──
|
|
185
|
-
let canInjectReminder = true;
|
|
186
195
|
const pendingReminders = [];
|
|
187
196
|
pi.events.on("loop:fire", (data) => {
|
|
188
197
|
const triggerInfo = typeof data.trigger === "string"
|
|
@@ -198,20 +207,6 @@ export default function (pi) {
|
|
|
198
207
|
.replace("%loop_id%", data.loopId || "unknown");
|
|
199
208
|
pendingReminders.push(reminder);
|
|
200
209
|
});
|
|
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
|
-
};
|
|
214
|
-
});
|
|
215
210
|
// ──────────────────────────────────────────────────
|
|
216
211
|
// Tool 1: LoopCreate
|
|
217
212
|
// ──────────────────────────────────────────────────
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -174,6 +174,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
174
174
|
widget.setUICtx(ctx.ui as UICtx);
|
|
175
175
|
upgradeStoreIfNeeded(ctx);
|
|
176
176
|
showPersistedLoops();
|
|
177
|
+
|
|
178
|
+
if (pendingReminders.length > 0) {
|
|
179
|
+
const reminder = pendingReminders.shift()!;
|
|
180
|
+
return {
|
|
181
|
+
message: {
|
|
182
|
+
customType: "pi-loop",
|
|
183
|
+
content: reminder,
|
|
184
|
+
display: false,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
177
188
|
});
|
|
178
189
|
|
|
179
190
|
pi.on("session_switch" as any, async (event: any, ctx: ExtensionContext) => {
|
|
@@ -195,7 +206,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
195
206
|
|
|
196
207
|
// ── System-reminder injection for loop fires ──
|
|
197
208
|
|
|
198
|
-
let canInjectReminder = true;
|
|
199
209
|
const pendingReminders: string[] = [];
|
|
200
210
|
|
|
201
211
|
pi.events.on("loop:fire", (data: any) => {
|
|
@@ -215,22 +225,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
215
225
|
pendingReminders.push(reminder);
|
|
216
226
|
});
|
|
217
227
|
|
|
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
|
-
};
|
|
232
|
-
});
|
|
233
|
-
|
|
234
228
|
// ──────────────────────────────────────────────────
|
|
235
229
|
// Tool 1: LoopCreate
|
|
236
230
|
// ──────────────────────────────────────────────────
|