fix(delegate-task): Wave 1 - fix polling timeout, resource cleanup, tool restrictions, idle dedup, auth-plugins JSONC, CLI runner hang

- fix(delegate-task): return error on poll timeout instead of silent null
- fix(delegate-task): ensure toast and session cleanup on all error paths with try/finally
- fix(delegate-task): apply agent tool restrictions in sync-prompt-sender
- fix(plugin): add symmetric idle dedup to prevent double hook triggers
- fix(cli): replace regex-based JSONC editing with jsonc-parser in auth-plugins
- fix(cli): abort event stream after completion and restore no-timeout default

All changes verified with tests and typecheck.
This commit is contained in:
YeonGyu-Kim
2026-02-10 19:09:22 +09:00
parent 5759e28eba
commit 47595f21a6
17 changed files with 1397 additions and 163 deletions
+40
View File
@@ -9,10 +9,12 @@ describe("pruneRecentSyntheticIdles", () => {
["ses_old", 1000],
["ses_new", 1600],
])
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
@@ -28,10 +30,12 @@ describe("pruneRecentSyntheticIdles", () => {
["ses_fresh_1", 1950],
["ses_fresh_2", 1980],
])
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 100,
})
@@ -45,10 +49,12 @@ describe("pruneRecentSyntheticIdles", () => {
it("handles empty Map without crashing (no-op on empty)", () => {
//#given
const recentSyntheticIdles = new Map<string, number>()
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
@@ -65,10 +71,12 @@ describe("pruneRecentSyntheticIdles", () => {
["ses_stale_2", 1200],
["ses_fresh_2", 1980],
])
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
@@ -88,10 +96,12 @@ describe("pruneRecentSyntheticIdles", () => {
["ses_old_2", 800],
["ses_old_3", 1200],
])
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
@@ -111,10 +121,12 @@ describe("pruneRecentSyntheticIdles", () => {
for (let i = 0; i < 60; i++) {
recentSyntheticIdles.set(`ses_fresh_${i}`, 1950 + i)
}
const recentRealIdles = new Map<string, number>()
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
@@ -130,4 +142,32 @@ describe("pruneRecentSyntheticIdles", () => {
expect(recentSyntheticIdles.has(`ses_fresh_${i}`)).toBe(true)
}
})
it("prunes both synthetic and real idle maps (dual map pruning)", () => {
//#given
const recentSyntheticIdles = new Map<string, number>([
["synthetic_old", 1000],
["synthetic_new", 1600],
])
const recentRealIdles = new Map<string, number>([
["real_old", 1000],
["real_new", 1600],
])
//#when
pruneRecentSyntheticIdles({
recentSyntheticIdles,
recentRealIdles,
now: 2000,
dedupWindowMs: 500,
})
//#then - both maps pruned
expect(recentSyntheticIdles.has("synthetic_old")).toBe(false)
expect(recentSyntheticIdles.has("synthetic_new")).toBe(true)
expect(recentRealIdles.has("real_old")).toBe(false)
expect(recentRealIdles.has("real_new")).toBe(true)
expect(recentSyntheticIdles.size).toBe(1)
expect(recentRealIdles.size).toBe(1)
})
})