@agfpd/iapeer 0.2.51 → 0.2.53

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.
@@ -40,6 +40,9 @@ const tmuxAvailable = spawnSync('tmux', ['-V'], { stdio: 'ignore' }).status ===
40
40
  const TARGET = 'fpw'
41
41
  const SESSION = `telegram-${TARGET}`
42
42
  const sockPath = () => join(sockDir, `tmux-iap-telegram-${TARGET}.sock`)
43
+ const TUI_TARGET = 'tq'
44
+ const TUI_SESSION = `codex-${TUI_TARGET}`
45
+ const tuiSockPath = () => join(sockDir, `tmux-iap-codex-${TUI_TARGET}.sock`)
43
46
 
44
47
  const callerRecord = {
45
48
  personality: 'boris',
@@ -79,6 +82,17 @@ function capturePane(): string {
79
82
  return r.stdout ?? ''
80
83
  }
81
84
 
85
+ function startTuiSession(): void {
86
+ const r = spawnSync('tmux', ['-S', tuiSockPath(), 'new-session', '-d', '-x', '200', '-y', '50', '-s', TUI_SESSION, 'cat'], {
87
+ encoding: 'utf8',
88
+ })
89
+ if (r.status !== 0) throw new Error(`tmux new-session failed: ${r.stderr}`)
90
+ }
91
+
92
+ function killTuiSession(): void {
93
+ spawnSync('tmux', ['-S', tuiSockPath(), 'kill-server'], { encoding: 'utf8' })
94
+ }
95
+
82
96
  beforeAll(() => {
83
97
  root = mkdtempSync(join(tmpdir(), 'fpw-'))
84
98
  sockDir = join(root, 'socks')
@@ -90,6 +104,7 @@ beforeAll(() => {
90
104
  peers: [
91
105
  { personality: 'boris', runtime: 'claude', runtimes: ['claude'], description: '', intelligence: 'artificial', cwd: '/tmp/boris' },
92
106
  { personality: TARGET, runtime: 'telegram', runtimes: ['telegram'], description: '', intelligence: 'artificial', cwd: root },
107
+ { personality: TUI_TARGET, runtime: 'codex', runtimes: ['codex'], description: '', intelligence: 'artificial', cwd: root },
93
108
  ],
94
109
  }),
95
110
  )
@@ -97,6 +112,7 @@ beforeAll(() => {
97
112
  })
98
113
  afterAll(() => {
99
114
  killTargetSession()
115
+ killTuiSession()
100
116
  if (prevRoot === undefined) delete process.env.IAPEER_ROOT
101
117
  else process.env.IAPEER_ROOT = prevRoot
102
118
  rmSync(root, { recursive: true, force: true })
@@ -218,6 +234,42 @@ describe.if(tmuxAvailable)('routeSend noteLiveTopic seam (live-delivered topic)'
218
234
  })
219
235
  })
220
236
 
237
+ describe.if(tmuxAvailable)('routeSend busy-composer queue seam', () => {
238
+ test('live local TUI hit can return fast queued ack instead of delivering synchronously', async () => {
239
+ startTuiSession()
240
+ const seen: string[] = []
241
+ const r = await routeSend(
242
+ caller,
243
+ { personality: TUI_TARGET, message: 'hold until operator submits', topic: 'composer-q' },
244
+ {
245
+ composerQueue: {
246
+ tryEnqueue: async ({ target, envelope, topic }) => {
247
+ seen.push(`${target.runtime}-${target.personality}:${topic}:${envelope.includes('hold until operator submits')}`)
248
+ return {
249
+ ok: true,
250
+ value: {
251
+ ok: true as const,
252
+ delivered_to: { personality: target.personality, runtime: target.runtime },
253
+ woke: false,
254
+ queued: true,
255
+ queuedBy: 'composer',
256
+ queueDepth: 1,
257
+ ts: 'now',
258
+ },
259
+ }
260
+ },
261
+ },
262
+ },
263
+ )
264
+ expect(r.ok).toBe(true)
265
+ if (!r.ok) return
266
+ expect(r.value.queued).toBe(true)
267
+ expect(r.value.queuedBy).toBe('composer')
268
+ expect(seen).toEqual([`codex-${TUI_TARGET}:composer-q:true`])
269
+ killTuiSession()
270
+ })
271
+ })
272
+
221
273
  // ─── Telegram sender policy (defect track 11.06) ─────────────────────────────
222
274
  // A sender with NO declared telegram presence (interfaces.telegram.bot|user_id)
223
275
  // must get a SYNCHRONOUS refusal when the delivery channel is telegram — the