pi-better-subagents 0.32.2 → 0.32.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/package.json
CHANGED
|
@@ -24,11 +24,12 @@ import { StoreError } from "./errors.ts";
|
|
|
24
24
|
import {
|
|
25
25
|
dependencyState,
|
|
26
26
|
mapOutbox,
|
|
27
|
+
ownerFromRow,
|
|
27
28
|
readOperationEvidence,
|
|
28
29
|
readOutboxRow,
|
|
29
30
|
requireWaitRow,
|
|
30
31
|
} from "./rows.ts";
|
|
31
|
-
import { columnJson, columnNullableText, columnText, getRows, run, type StoreContext } from "./sqlite.ts";
|
|
32
|
+
import { columnJson, columnNullableText, columnNumber, columnText, getRows, run, type StoreContext } from "./sqlite.ts";
|
|
32
33
|
import type {
|
|
33
34
|
ClaimOutboxInput,
|
|
34
35
|
OutboxDispatchClaim,
|
|
@@ -280,6 +281,23 @@ export function listOutbox(ctx: StoreContext, filter: OutboxFilter = {}): Outbox
|
|
|
280
281
|
).map((row) => mapOutbox(ctx, row));
|
|
281
282
|
}
|
|
282
283
|
|
|
284
|
+
/** Find recipients with deliverable dependencies without loading each event's evidence. */
|
|
285
|
+
export function listDispatchableOutboxRecipients(ctx: StoreContext): Array<{ recipient: OwnerIdentity; count: number }> {
|
|
286
|
+
return getRows(
|
|
287
|
+
ctx,
|
|
288
|
+
`SELECT recipient_kind, recipient_session_id, recipient_workspace, recipient_branch_id, recipient_goal_id,
|
|
289
|
+
count(*) AS pending_count
|
|
290
|
+
FROM outbox_events
|
|
291
|
+
WHERE state = 'pending' AND event_type = 'dependency-ready'
|
|
292
|
+
AND EXISTS (SELECT 1 FROM waits w WHERE w.wait_id = outbox_events.wait_id
|
|
293
|
+
AND w.generation = outbox_events.generation
|
|
294
|
+
AND w.phase IN (${placeholders(DELIVERABLE_WAIT_PHASES.length)}))
|
|
295
|
+
GROUP BY recipient_kind, recipient_session_id, recipient_workspace, recipient_branch_id, recipient_goal_id
|
|
296
|
+
ORDER BY min(created_at), min(event_id)`,
|
|
297
|
+
...DELIVERABLE_WAIT_PHASES,
|
|
298
|
+
).map((row) => ({ recipient: ownerFromRow(row, "recipient"), count: columnNumber(row, "pending_count") }));
|
|
299
|
+
}
|
|
300
|
+
|
|
283
301
|
function readDispatchClaim(row: Record<string, unknown>): OutboxDispatchClaim | null {
|
|
284
302
|
return columnJson<OutboxDispatchClaim>(row, "dispatch_claim_json");
|
|
285
303
|
}
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
} from "./waits.ts";
|
|
59
59
|
import {
|
|
60
60
|
claimOutbox as writeOutboxClaim,
|
|
61
|
+
listDispatchableOutboxRecipients as readDispatchableOutboxRecipients,
|
|
61
62
|
listOutbox as readOutbox,
|
|
62
63
|
markOutboxDelivered as writeOutboxDelivery,
|
|
63
64
|
releaseOutbox as writeOutboxRelease,
|
|
@@ -272,6 +273,8 @@ export interface Store {
|
|
|
272
273
|
// ---- outbox ----
|
|
273
274
|
|
|
274
275
|
listOutbox(filter?: OutboxFilter): OutboxEventRecord[];
|
|
276
|
+
/** Lightweight dispatch candidates; evidence is read only after a claim succeeds. */
|
|
277
|
+
listDispatchableOutboxRecipients(): Array<{ recipient: OwnerIdentity; count: number }>;
|
|
275
278
|
/** Claim pending deliveries for a `ready`/`resuming` generation. */
|
|
276
279
|
claimOutbox(input: ClaimOutboxInput): OutboxEventRecord[];
|
|
277
280
|
/** Mark a claimed delivery delivered; the result is still unconsumed. */
|
|
@@ -457,6 +460,10 @@ export function openStore(options: StoreOptions): Store {
|
|
|
457
460
|
alive();
|
|
458
461
|
return readOutbox(ctx, filter);
|
|
459
462
|
},
|
|
463
|
+
listDispatchableOutboxRecipients() {
|
|
464
|
+
alive();
|
|
465
|
+
return readDispatchableOutboxRecipients(ctx);
|
|
466
|
+
},
|
|
460
467
|
claimOutbox(input) {
|
|
461
468
|
alive();
|
|
462
469
|
return writeOutboxClaim(ctx, input);
|