agent-relay-server 0.10.15 → 0.10.17
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 +1 -1
- package/src/db.ts +12 -4
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -2555,10 +2555,18 @@ export function listQueuedMessages(target: string, limit = 100): Message[] {
|
|
|
2555
2555
|
export function resolveQueuedPolicyMessages(policyName: string, agentId: string): Message[] {
|
|
2556
2556
|
const target = `policy:${policyName}`;
|
|
2557
2557
|
const rows = db.prepare(`
|
|
2558
|
-
SELECT id
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2558
|
+
SELECT m.id
|
|
2559
|
+
FROM messages m
|
|
2560
|
+
WHERE m.to_target = ?
|
|
2561
|
+
AND m.delivery_status IN ('queued', 'pending')
|
|
2562
|
+
AND NOT EXISTS (SELECT 1 FROM message_reads mr WHERE mr.message_id = m.id)
|
|
2563
|
+
AND (
|
|
2564
|
+
m.delivery_status = 'queued'
|
|
2565
|
+
OR m.resolved_to_agent IS NULL
|
|
2566
|
+
OR m.resolved_to_agent != ?
|
|
2567
|
+
)
|
|
2568
|
+
ORDER BY COALESCE(m.queued_at, m.created_at) ASC, m.id ASC
|
|
2569
|
+
`).all(target, agentId) as Array<{ id: number }>;
|
|
2562
2570
|
if (rows.length === 0) return [];
|
|
2563
2571
|
const ids = rows.map((row) => row.id);
|
|
2564
2572
|
const placeholders = ids.map(() => "?").join(",");
|