agentix-cli 0.193.0 → 0.195.0

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.
Files changed (161) hide show
  1. package/README.md +1 -1
  2. package/apps/mac-helper/Sources/AgentXHelper/Presence.swift +70 -6
  3. package/apps/mac-helper/Sources/AgentXHelper/PresenceTag.swift +42 -5
  4. package/apps/mac-helper/Sources/AgentXHelper/main.swift +2 -1
  5. package/apps/mac-voice/Sources/AgentXVoice/AgentClient.swift +107 -4
  6. package/apps/mac-voice/Sources/AgentXVoice/Config.swift +0 -9
  7. package/apps/mac-voice/Sources/AgentXVoice/HistoryWindow.swift +3 -2
  8. package/apps/mac-voice/Sources/AgentXVoice/OpenRequests.swift +276 -8
  9. package/apps/mac-voice/Sources/AgentXVoice/RequestsWindow.swift +357 -26
  10. package/apps/mac-voice/Sources/AgentXVoice/SettingsWindow.swift +27 -0
  11. package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +17 -2
  12. package/apps/mac-voice/Sources/AgentXVoice/VoiceSettings.swift +23 -1
  13. package/apps/mac-voice/Sources/AgentXVoice/main.swift +335 -30
  14. package/dist/{App-6TNGC3UR.js → App-HBM52GXI.js} +2 -2
  15. package/dist/{ChatApp-FUDLZ6HZ.js → ChatApp-N4P7M2TD.js} +2 -2
  16. package/dist/{absorb-eval-YSWPPGQF.js → absorb-eval-HRWWPKT3.js} +2 -2
  17. package/dist/{adapter-EEBNOFDS.js → adapter-X6T3YBUB.js} +2 -2
  18. package/dist/{agent-QX2POUEM.js → agent-3B4RMEDI.js} +2 -2
  19. package/dist/{board-dashboard-VVFHNABJ.js → board-dashboard-ZIDDOCOO.js} +1866 -6115
  20. package/dist/board-dashboard-ZIDDOCOO.js.map +1 -0
  21. package/dist/{chunk-2O72AHK5.js → chunk-2GCPSAXQ.js} +2 -2
  22. package/dist/{chunk-KHKG7H6Q.js → chunk-2KYGPVTX.js} +2 -2
  23. package/dist/chunk-3FZ6WHKX.js +2 -0
  24. package/dist/{chunk-MQRAQJSS.js.map → chunk-3FZ6WHKX.js.map} +1 -1
  25. package/dist/{chunk-HNA4BW47.js → chunk-6NQ7KYJH.js} +2 -2
  26. package/dist/{chunk-Z2NYUCTE.js → chunk-7L54Z4EH.js} +2 -2
  27. package/dist/{chunk-EH7Y2W77.js → chunk-BOCLWYWL.js} +2 -2
  28. package/dist/chunk-F2FJXKDG.js +7 -0
  29. package/dist/{chunk-DS2ZIVIH.js.map → chunk-F2FJXKDG.js.map} +1 -1
  30. package/dist/{chunk-OYXB6KZX.js → chunk-F3CMNSON.js} +2 -2
  31. package/dist/{chunk-52NME3AU.js → chunk-FO762MEC.js} +2 -2
  32. package/dist/{chunk-AAL5WIXB.js → chunk-HNZEXUNM.js} +2 -2
  33. package/dist/{chunk-H5XBQWAI.js → chunk-HOZZUN47.js} +2 -2
  34. package/dist/chunk-I45E5TLK.js +934 -0
  35. package/dist/chunk-I45E5TLK.js.map +1 -0
  36. package/dist/{chunk-Q7ZPW55P.js → chunk-K2BEV3BD.js} +2 -2
  37. package/dist/{chunk-QTBFMRJ2.js → chunk-KE6BF4ZJ.js} +2 -2
  38. package/dist/{chunk-DACZSUCN.js → chunk-KXJRXRSD.js} +2 -2
  39. package/dist/{chunk-TDZDIDFG.js → chunk-LQIF2OHS.js} +2 -2
  40. package/dist/chunk-M2E3CNFS.js +38 -0
  41. package/dist/chunk-M2E3CNFS.js.map +1 -0
  42. package/dist/{chunk-22WO5X4L.js → chunk-MB5CBY2C.js} +106 -106
  43. package/dist/chunk-MB5CBY2C.js.map +1 -0
  44. package/dist/{chunk-JGZ6CA5L.js → chunk-MC3ZZA5G.js} +2 -2
  45. package/dist/{chunk-PSP3NAFU.js → chunk-OEG476JY.js} +79 -76
  46. package/dist/chunk-OEG476JY.js.map +1 -0
  47. package/dist/{chunk-6ZAQ3IT5.js → chunk-P6WSD2UR.js} +23 -23
  48. package/dist/chunk-P6WSD2UR.js.map +1 -0
  49. package/dist/{chunk-GLYBXXO7.js → chunk-PMSL4A5Y.js} +3 -3
  50. package/dist/{chunk-VK2TW3RL.js → chunk-PO2SORKY.js} +2 -2
  51. package/dist/{chunk-N56EHPTR.js → chunk-PX7PWXBI.js} +2 -2
  52. package/dist/{chunk-EI3TZ52P.js → chunk-RW5FKJRE.js} +2 -2
  53. package/dist/{chunk-6FUWODBV.js → chunk-UOIWIVU3.js} +2 -2
  54. package/dist/{chunk-2VQ3VKBR.js → chunk-VX4PSOKU.js} +2 -2
  55. package/dist/{chunk-FEXG2PKQ.js → chunk-XH36J3Z2.js} +2 -2
  56. package/dist/{chunk-462FRP7L.js → chunk-XQF7UUZK.js} +332 -319
  57. package/dist/chunk-XQF7UUZK.js.map +1 -0
  58. package/dist/{chunk-MQV3IU6F.js → chunk-ZALVAXQ4.js} +2 -2
  59. package/dist/cli.js +1 -1
  60. package/dist/{client-5USANRIL.js → client-YN3T56NM.js} +2 -2
  61. package/dist/{config-N7DHUZMH.js → config-G7T3TMWE.js} +2 -2
  62. package/dist/{config-mutate-OVUXNS5X.js → config-mutate-6CRKZQVQ.js} +2 -2
  63. package/dist/config-mutator-7VS3J5BY.js +2 -0
  64. package/dist/{contributions-LTDE6UOQ.js → contributions-6VZ4OXJ5.js} +2 -2
  65. package/dist/{doctor-C3DTKR7C.js → doctor-GFZZTK7C.js} +2 -2
  66. package/dist/{follow-up-tool-NCFOTJ5Y.js → follow-up-tool-NVP56W7E.js} +2 -2
  67. package/dist/{hub-F3X7NL4B.js → hub-B434CABZ.js} +2 -2
  68. package/dist/index.d.ts +38 -6
  69. package/dist/index.js +1 -1
  70. package/dist/{program-6HWZZ2D3.js → program-DW6VZ6LN.js} +238 -238
  71. package/dist/program-DW6VZ6LN.js.map +1 -0
  72. package/dist/{promote-FSOPSHJ4.js → promote-3P6PGJOW.js} +2 -2
  73. package/dist/{query-UDRKDTSB.js → query-E4V7TS5S.js} +2 -2
  74. package/dist/{query-settings-DJGEGG62.js → query-settings-C5UBKJMN.js} +2 -2
  75. package/dist/{registry-AVGT5KPR.js → registry-IG324PR3.js} +2 -2
  76. package/dist/{request-planner-SAQX26AR.js → request-planner-G6IAUMSE.js} +2 -2
  77. package/dist/{review-candidates-67MPNU42.js → review-candidates-ZL2SJXWC.js} +2 -2
  78. package/dist/{routing-7DUO5PI7.js → routing-2IBIZYQU.js} +2 -2
  79. package/dist/schedule-tool-QCTT2R3B.js +2 -0
  80. package/dist/{scheduler-3IADVHIN.js → scheduler-ZGB7IKZQ.js} +2 -2
  81. package/dist/{seat-YWSYQBCW.js → seat-CFY7LMPS.js} +2 -2
  82. package/dist/{select-PA7AHZ3W.js → select-MU52ACKG.js} +2 -2
  83. package/dist/self-ELWZIMVY.js +2 -0
  84. package/dist/{set-enabled-DD6L2ZQ6.js → set-enabled-XRNSYEI3.js} +2 -2
  85. package/dist/{sprint-tool-PKJA6LYF.js → sprint-tool-E4MABD2N.js} +2 -2
  86. package/dist/{tool-WJ72TBMV.js → tool-V5Z4KWK7.js} +2 -2
  87. package/dist/{tool-PJSLWK45.js → tool-W6M7GYRZ.js} +2 -2
  88. package/dist/{tool-KOGZBOCR.js → tool-ZYVT4VUU.js} +2 -2
  89. package/dist/{wiki-HQBMWH23.js → wiki-VP6XRWIS.js} +2 -2
  90. package/dist/wiki-enrich-LUFXPUYY.js +2 -0
  91. package/package.json +1 -1
  92. package/dist/board-dashboard-VVFHNABJ.js.map +0 -1
  93. package/dist/chunk-22WO5X4L.js.map +0 -1
  94. package/dist/chunk-462FRP7L.js.map +0 -1
  95. package/dist/chunk-6ZAQ3IT5.js.map +0 -1
  96. package/dist/chunk-BKTKJNCR.js +0 -36
  97. package/dist/chunk-BKTKJNCR.js.map +0 -1
  98. package/dist/chunk-DS2ZIVIH.js +0 -7
  99. package/dist/chunk-MQRAQJSS.js +0 -2
  100. package/dist/chunk-PSP3NAFU.js.map +0 -1
  101. package/dist/chunk-RDENYWNG.js +0 -898
  102. package/dist/chunk-RDENYWNG.js.map +0 -1
  103. package/dist/config-mutator-OK7CDCHW.js +0 -2
  104. package/dist/program-6HWZZ2D3.js.map +0 -1
  105. package/dist/schedule-tool-LZOW5SVQ.js +0 -2
  106. package/dist/self-KACQLLDA.js +0 -2
  107. package/dist/wiki-enrich-7RPM5DQF.js +0 -2
  108. /package/dist/{App-6TNGC3UR.js.map → App-HBM52GXI.js.map} +0 -0
  109. /package/dist/{ChatApp-FUDLZ6HZ.js.map → ChatApp-N4P7M2TD.js.map} +0 -0
  110. /package/dist/{absorb-eval-YSWPPGQF.js.map → absorb-eval-HRWWPKT3.js.map} +0 -0
  111. /package/dist/{adapter-EEBNOFDS.js.map → adapter-X6T3YBUB.js.map} +0 -0
  112. /package/dist/{agent-QX2POUEM.js.map → agent-3B4RMEDI.js.map} +0 -0
  113. /package/dist/{chunk-2O72AHK5.js.map → chunk-2GCPSAXQ.js.map} +0 -0
  114. /package/dist/{chunk-KHKG7H6Q.js.map → chunk-2KYGPVTX.js.map} +0 -0
  115. /package/dist/{chunk-HNA4BW47.js.map → chunk-6NQ7KYJH.js.map} +0 -0
  116. /package/dist/{chunk-Z2NYUCTE.js.map → chunk-7L54Z4EH.js.map} +0 -0
  117. /package/dist/{chunk-EH7Y2W77.js.map → chunk-BOCLWYWL.js.map} +0 -0
  118. /package/dist/{chunk-OYXB6KZX.js.map → chunk-F3CMNSON.js.map} +0 -0
  119. /package/dist/{chunk-52NME3AU.js.map → chunk-FO762MEC.js.map} +0 -0
  120. /package/dist/{chunk-AAL5WIXB.js.map → chunk-HNZEXUNM.js.map} +0 -0
  121. /package/dist/{chunk-H5XBQWAI.js.map → chunk-HOZZUN47.js.map} +0 -0
  122. /package/dist/{chunk-Q7ZPW55P.js.map → chunk-K2BEV3BD.js.map} +0 -0
  123. /package/dist/{chunk-QTBFMRJ2.js.map → chunk-KE6BF4ZJ.js.map} +0 -0
  124. /package/dist/{chunk-DACZSUCN.js.map → chunk-KXJRXRSD.js.map} +0 -0
  125. /package/dist/{chunk-TDZDIDFG.js.map → chunk-LQIF2OHS.js.map} +0 -0
  126. /package/dist/{chunk-JGZ6CA5L.js.map → chunk-MC3ZZA5G.js.map} +0 -0
  127. /package/dist/{chunk-GLYBXXO7.js.map → chunk-PMSL4A5Y.js.map} +0 -0
  128. /package/dist/{chunk-VK2TW3RL.js.map → chunk-PO2SORKY.js.map} +0 -0
  129. /package/dist/{chunk-N56EHPTR.js.map → chunk-PX7PWXBI.js.map} +0 -0
  130. /package/dist/{chunk-EI3TZ52P.js.map → chunk-RW5FKJRE.js.map} +0 -0
  131. /package/dist/{chunk-6FUWODBV.js.map → chunk-UOIWIVU3.js.map} +0 -0
  132. /package/dist/{chunk-2VQ3VKBR.js.map → chunk-VX4PSOKU.js.map} +0 -0
  133. /package/dist/{chunk-FEXG2PKQ.js.map → chunk-XH36J3Z2.js.map} +0 -0
  134. /package/dist/{chunk-MQV3IU6F.js.map → chunk-ZALVAXQ4.js.map} +0 -0
  135. /package/dist/{client-5USANRIL.js.map → client-YN3T56NM.js.map} +0 -0
  136. /package/dist/{config-N7DHUZMH.js.map → config-G7T3TMWE.js.map} +0 -0
  137. /package/dist/{config-mutate-OVUXNS5X.js.map → config-mutate-6CRKZQVQ.js.map} +0 -0
  138. /package/dist/{config-mutator-OK7CDCHW.js.map → config-mutator-7VS3J5BY.js.map} +0 -0
  139. /package/dist/{contributions-LTDE6UOQ.js.map → contributions-6VZ4OXJ5.js.map} +0 -0
  140. /package/dist/{doctor-C3DTKR7C.js.map → doctor-GFZZTK7C.js.map} +0 -0
  141. /package/dist/{follow-up-tool-NCFOTJ5Y.js.map → follow-up-tool-NVP56W7E.js.map} +0 -0
  142. /package/dist/{hub-F3X7NL4B.js.map → hub-B434CABZ.js.map} +0 -0
  143. /package/dist/{promote-FSOPSHJ4.js.map → promote-3P6PGJOW.js.map} +0 -0
  144. /package/dist/{query-UDRKDTSB.js.map → query-E4V7TS5S.js.map} +0 -0
  145. /package/dist/{query-settings-DJGEGG62.js.map → query-settings-C5UBKJMN.js.map} +0 -0
  146. /package/dist/{registry-AVGT5KPR.js.map → registry-IG324PR3.js.map} +0 -0
  147. /package/dist/{request-planner-SAQX26AR.js.map → request-planner-G6IAUMSE.js.map} +0 -0
  148. /package/dist/{review-candidates-67MPNU42.js.map → review-candidates-ZL2SJXWC.js.map} +0 -0
  149. /package/dist/{routing-7DUO5PI7.js.map → routing-2IBIZYQU.js.map} +0 -0
  150. /package/dist/{schedule-tool-LZOW5SVQ.js.map → schedule-tool-QCTT2R3B.js.map} +0 -0
  151. /package/dist/{scheduler-3IADVHIN.js.map → scheduler-ZGB7IKZQ.js.map} +0 -0
  152. /package/dist/{seat-YWSYQBCW.js.map → seat-CFY7LMPS.js.map} +0 -0
  153. /package/dist/{select-PA7AHZ3W.js.map → select-MU52ACKG.js.map} +0 -0
  154. /package/dist/{self-KACQLLDA.js.map → self-ELWZIMVY.js.map} +0 -0
  155. /package/dist/{set-enabled-DD6L2ZQ6.js.map → set-enabled-XRNSYEI3.js.map} +0 -0
  156. /package/dist/{sprint-tool-PKJA6LYF.js.map → sprint-tool-E4MABD2N.js.map} +0 -0
  157. /package/dist/{tool-WJ72TBMV.js.map → tool-V5Z4KWK7.js.map} +0 -0
  158. /package/dist/{tool-PJSLWK45.js.map → tool-W6M7GYRZ.js.map} +0 -0
  159. /package/dist/{tool-KOGZBOCR.js.map → tool-ZYVT4VUU.js.map} +0 -0
  160. /package/dist/{wiki-HQBMWH23.js.map → wiki-VP6XRWIS.js.map} +0 -0
  161. /package/dist/{wiki-enrich-7RPM5DQF.js.map → wiki-enrich-LUFXPUYY.js.map} +0 -0
package/README.md CHANGED
@@ -66,7 +66,7 @@ What it costs depends on your model account (a Claude subscription, or an API ke
66
66
 
67
67
  **First result you can see.** **Terminal:** `agentx content drafts` lists one draft per planned post, each with the past posts it followed.
68
68
 
69
- ![A LinkedIn post waiting in Approvals, with the past posts it followed](docs/public/screenshots/content/approvals-post.png)
69
+ ![A drafted post waiting in Needs you on the Hub, under the Drafts chip](docs/public/screenshots/wall/needs-you-drafts.png)
70
70
 
71
71
  [Draft posts in your voice](docs/jobs/content.md)
72
72
 
@@ -14,11 +14,20 @@ import AppKit
14
14
  /// {"cmd":"say","text":"The export button is top right."}
15
15
  /// {"cmd":"clear"} drop the highlight
16
16
  /// {"cmd":"park"} return beside the person's own pointer, no highlight
17
+ /// {"cmd":"wait","seconds":45} the owner waits on the person: Skip and
18
+ /// a countdown on the tag; 0 takes them away
17
19
  /// {"cmd":"ping"} nothing; keeps an idle overlay alive
18
20
  ///
19
21
  /// and reports on stdout what the person did to it, one JSON object per line:
20
22
  ///
21
23
  /// {"event":"dismiss"} the × on the name tag was clicked; it then fades out
24
+ /// {"event":"skip"} Skip was clicked: the owner stops waiting
25
+ ///
26
+ /// The arrow rests (#1591): `--rest` seconds after its last move or wait
27
+ /// it fades out with its highlight, and comes back on the next move. A
28
+ /// park while resting moves it unseen. The tag stays, so the × and Skip
29
+ /// are always there to use. `--tag-only` draws no arrow at all, only the
30
+ /// tag: the controls of a lesson whose pointer is the character.
22
31
  ///
23
32
  /// Coordinates are accessibility coordinates (top-left origin, global),
24
33
  /// the same as `read`, `ocr` and `point`.
@@ -137,14 +146,21 @@ enum Presence {
137
146
  let ring: NSPanel
138
147
  let color: NSColor
139
148
  let posFile: String?
149
+ let tagOnly: Bool
150
+ /// Seconds after the last move or wait before the arrow rests; 0 never.
151
+ let rest: TimeInterval
152
+ var lastAction = Date()
153
+ private(set) var resting = false
140
154
  var at: CGPoint // tip position, AppKit coordinates
141
155
  /// The tag's top-left once the person has dragged it; nil rides with the arrow.
142
156
  var pinned: NSPoint?
143
157
  var timer: Timer?
144
158
 
145
- init(color: NSColor, initial: String, name: String, posFile: String?) {
159
+ init(color: NSColor, initial: String, name: String, posFile: String?, tagOnly: Bool = false, rest: TimeInterval = 0) {
146
160
  self.color = color
147
161
  self.posFile = posFile
162
+ self.tagOnly = tagOnly
163
+ self.rest = rest
148
164
  arrow = Presence.panel(NSRect(origin: .zero, size: ArrowView.size))
149
165
  arrow.contentView = ArrowView(color: color)
150
166
  tag = PresenceTag(color: color, initial: initial, name: name)
@@ -168,17 +184,47 @@ enum Presence {
168
184
  self.place(self.at)
169
185
  }
170
186
  place(at)
171
- for p in [arrow, tagPanel] {
187
+ for p in tagOnly ? [tagPanel] : [arrow, tagPanel] {
172
188
  p.alphaValue = 0
173
189
  p.orderFrontRegardless()
174
190
  }
175
191
  NSAnimationContext.runAnimationGroup { ctx in
176
192
  ctx.duration = 0.2
177
- arrow.animator().alphaValue = 1
193
+ if !tagOnly { arrow.animator().alphaValue = 1 }
178
194
  tagPanel.animator().alphaValue = 1
179
195
  }
180
196
  }
181
197
 
198
+ /// Top centre of the main screen, below a window's tab bar and
199
+ /// toolbar so it covers neither: where a tag with no arrow to ride
200
+ /// sits until it is dragged.
201
+ static func topCentre(width: CGFloat) -> NSPoint {
202
+ let v = NSScreen.main?.visibleFrame ?? NSRect(x: 0, y: 0, width: 1440, height: 900)
203
+ return NSPoint(x: v.midX - width / 2, y: v.maxY - 96)
204
+ }
205
+
206
+ /// No move or wait for `rest` seconds: the arrow and its highlight
207
+ /// fade out. The overlay stays, and so does the tag.
208
+ func restIfIdle() {
209
+ guard !tagOnly, rest > 0, !resting, Date().timeIntervalSince(lastAction) > rest else { return }
210
+ resting = true
211
+ ring.orderOut(nil)
212
+ NSAnimationContext.runAnimationGroup { ctx in
213
+ ctx.duration = 0.4
214
+ arrow.animator().alphaValue = 0
215
+ }
216
+ }
217
+
218
+ private func wake() {
219
+ lastAction = Date()
220
+ guard resting else { return }
221
+ resting = false
222
+ NSAnimationContext.runAnimationGroup { ctx in
223
+ ctx.duration = 0.2
224
+ arrow.animator().alphaValue = 1
225
+ }
226
+ }
227
+
182
228
  /// Just below and right of the person's real pointer, so handing
183
229
  /// back reads as returning to them, without covering their cursor.
184
230
  static func parking() -> CGPoint {
@@ -192,6 +238,11 @@ enum Presence {
192
238
  arrow.setFrameOrigin(NSPoint(x: tip.x - ArrowView.tip.x, y: tip.y - ArrowView.tip.y))
193
239
  if tag.dragged { return }
194
240
  let size = tagPanel.frame.size
241
+ if tagOnly {
242
+ let top = pinned ?? Controller.topCentre(width: size.width)
243
+ tagPanel.setFrameOrigin(NSPoint(x: top.x, y: top.y - size.height))
244
+ return
245
+ }
195
246
  var top = pinned ?? NSPoint(x: tip.x + 20, y: tip.y - 26)
196
247
  if pinned == nil {
197
248
  // Near the right edge the tag sits to the left of the arrow.
@@ -230,7 +281,8 @@ enum Presence {
230
281
  func handle(_ obj: [String: Any]) {
231
282
  switch obj["cmd"] as? String {
232
283
  case "move":
233
- guard let x = obj["x"] as? Double, let y = obj["y"] as? Double else { return }
284
+ guard !tagOnly, let x = obj["x"] as? Double, let y = obj["y"] as? Double else { return }
285
+ wake()
234
286
  let w = obj["w"] as? Double ?? 0, h = obj["h"] as? Double ?? 0
235
287
  let rect = CGRect(x: x, y: y, width: w, height: h)
236
288
  // Aim just inside the control's lower-left third, so the
@@ -244,8 +296,14 @@ enum Presence {
244
296
  case "clear":
245
297
  highlight(nil)
246
298
  case "park":
299
+ guard !tagOnly else { return }
300
+ // Resting, it goes back unseen: only a move shows it again.
247
301
  highlight(nil)
248
302
  glide(to: Controller.parking())
303
+ case "wait":
304
+ lastAction = Date()
305
+ tag.setWait(obj["seconds"] as? Double ?? 0)
306
+ place(at)
249
307
  default:
250
308
  break
251
309
  }
@@ -271,10 +329,11 @@ enum Presence {
271
329
 
272
330
  /// Read commands until stdin closes, the owner dies, or it goes idle.
273
331
  static func run(name: String, initial: String, colorHex: String?, parent: pid_t?, idle: TimeInterval,
274
- posFile: String? = nil) {
332
+ posFile: String? = nil, tagOnly: Bool = false, rest: TimeInterval = 0) {
275
333
  let app = NSApplication.shared
276
334
  app.setActivationPolicy(.accessory)
277
- let ctl = Controller(color: color(hex: colorHex), initial: initial, name: name, posFile: posFile)
335
+ let ctl = Controller(color: color(hex: colorHex), initial: initial, name: name, posFile: posFile,
336
+ tagOnly: tagOnly, rest: rest)
278
337
  var lastCommand = Date()
279
338
  var quitting = false
280
339
  // Main thread only. The fade is a courtesy: exit follows regardless.
@@ -289,6 +348,11 @@ enum Presence {
289
348
  FileHandle.standardOutput.write("{\"event\":\"dismiss\"}\n".data(using: .utf8)!)
290
349
  quit()
291
350
  }
351
+ ctl.tag.onSkip = {
352
+ FileHandle.standardOutput.write("{\"event\":\"skip\"}\n".data(using: .utf8)!)
353
+ }
354
+ // Checked often enough that the rest lands close to its second.
355
+ Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in ctl.restIfIdle() }
292
356
  DispatchQueue(label: "tn.acme.agentx.presence.stdin").async {
293
357
  while let line = readLine(strippingNewline: true) {
294
358
  guard let data = line.data(using: .utf8),
@@ -8,6 +8,7 @@ import AppKit
8
8
  ///
9
9
  /// drag anywhere move it; it stays there (pinned) for this agent
10
10
  /// click × close: the owner ends what it was showing
11
+ /// click Skip while the owner waits on the person: stop waiting
11
12
  /// double-click bubble dismiss the bubble for the rest of this overlay
12
13
  /// double-click name unpin; it rides next to the arrow again
13
14
  ///
@@ -29,8 +30,15 @@ final class PresenceTag: NSView {
29
30
  var onUnpin: (() -> Void)?
30
31
  /// Called when the × in the badge row is clicked.
31
32
  var onClose: (() -> Void)?
33
+ /// Called when Skip is clicked, while there is a wait to skip.
34
+ var onSkip: (() -> Void)?
32
35
  /// A click that started on the × and has not moved: a close, not a drag.
33
36
  private var pressingClose = false
37
+ private var pressingSkip = false
38
+ /// While the owner waits on the person: when the wait runs out. Skip
39
+ /// and the seconds left show in the badge row until then.
40
+ private var waitUntil: Date?
41
+ private var countdown: Timer?
34
42
  /// A double-click on the bubble hides it; later lines stay hidden too.
35
43
  private(set) var dismissed = false
36
44
 
@@ -61,9 +69,27 @@ final class PresenceTag: NSView {
61
69
 
62
70
  private static let nameAttrs: [NSAttributedString.Key: Any] = [.font: NSFont.systemFont(ofSize: 11, weight: .semibold)]
63
71
  private var nameWidth: CGFloat { (name as NSString).size(withAttributes: PresenceTag.nameAttrs).width + 14 }
64
- private var rowWidth: CGFloat { 24 + 4 + nameWidth + 4 + 18 }
65
- /// The close button, right of the name pill.
66
- private var closeRect: NSRect { NSRect(x: 24 + 4 + nameWidth + 4, y: bounds.maxY - 24 + 3, width: 18, height: 18) }
72
+ /// "Skip · 45s" is measured at its widest, so the row does not jitter.
73
+ private static let skipWidth: CGFloat = ("Skip · 88s" as NSString).size(withAttributes: nameAttrs).width + 14
74
+ private var skipShown: Bool { waitUntil != nil }
75
+ private var rowWidth: CGFloat { 24 + 4 + nameWidth + 4 + (skipShown ? PresenceTag.skipWidth + 4 : 0) + 18 }
76
+ /// Skip, right of the name pill, while there is a wait.
77
+ private var skipRect: NSRect { NSRect(x: 24 + 4 + nameWidth + 4, y: bounds.maxY - 24 + 3, width: PresenceTag.skipWidth, height: 18) }
78
+ /// The close button, at the end of the row.
79
+ private var closeRect: NSRect { NSRect(x: rowWidth - 18, y: bounds.maxY - 24 + 3, width: 18, height: 18) }
80
+
81
+ /// Show Skip and count down `seconds`; 0 or less hides them.
82
+ func setWait(_ seconds: Double) {
83
+ countdown?.invalidate()
84
+ countdown = nil
85
+ waitUntil = seconds > 0 ? Date().addingTimeInterval(seconds) : nil
86
+ if waitUntil != nil {
87
+ countdown = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] _ in self?.needsDisplay = true }
88
+ }
89
+ refit()
90
+ }
91
+
92
+ private var secondsLeft: Int { max(0, Int((waitUntil?.timeIntervalSinceNow ?? 0).rounded(.up))) }
67
93
 
68
94
  override var fittingSize: NSSize {
69
95
  guard !box.isHidden else { return NSSize(width: rowWidth, height: PresenceTag.rowHeight) }
@@ -104,6 +130,14 @@ final class PresenceTag: NSView {
104
130
  color.setFill(); NSBezierPath(roundedRect: pill, xRadius: 9, yRadius: 9).fill()
105
131
  draw(name, in: pill, size: 11, weight: .semibold)
106
132
 
133
+ if skipShown {
134
+ let skip = skipRect
135
+ Brand.paper.setFill(); NSBezierPath(roundedRect: skip, xRadius: 9, yRadius: 9).fill()
136
+ color.setStroke()
137
+ let edge = NSBezierPath(roundedRect: skip.insetBy(dx: 0.75, dy: 0.75), xRadius: 8.25, yRadius: 8.25); edge.lineWidth = 1.5; edge.stroke()
138
+ draw("Skip · \(secondsLeft)s", in: skip, size: 11, weight: .semibold, color: color)
139
+ }
140
+
107
141
  let close = closeRect
108
142
  Brand.paper.setFill(); NSBezierPath(ovalIn: close).fill()
109
143
  color.setStroke()
@@ -139,7 +173,9 @@ final class PresenceTag: NSView {
139
173
  dragFrom = nil
140
174
  return
141
175
  }
142
- pressingClose = closeRect.insetBy(dx: -3, dy: -3).contains(convert(event.locationInWindow, from: nil))
176
+ let p = convert(event.locationInWindow, from: nil)
177
+ pressingClose = closeRect.insetBy(dx: -3, dy: -3).contains(p)
178
+ pressingSkip = skipShown && skipRect.insetBy(dx: -2, dy: -3).contains(p)
143
179
  dragFrom = NSEvent.mouseLocation
144
180
  windowFrom = window?.frame.origin ?? .zero
145
181
  dragged = false
@@ -155,8 +191,9 @@ final class PresenceTag: NSView {
155
191
  }
156
192
 
157
193
  override func mouseUp(with event: NSEvent) {
158
- defer { dragFrom = nil; dragged = false; pressingClose = false }
194
+ defer { dragFrom = nil; dragged = false; pressingClose = false; pressingSkip = false }
159
195
  if pressingClose && !dragged { onClose?(); return }
196
+ if pressingSkip && !dragged { setWait(0); onSkip?(); return }
160
197
  guard dragged, let w = window else { return }
161
198
  onPin?(NSPoint(x: w.frame.minX, y: w.frame.maxY))
162
199
  }
@@ -314,7 +314,8 @@ case "presence":
314
314
  Presence.run(name: name, initial: flag("initial") ?? String(name.prefix(1)).uppercased(),
315
315
  colorHex: flag("color"), parent: flag("parent").flatMap { pid_t($0) },
316
316
  idle: flag("idle").flatMap { TimeInterval($0) } ?? 60,
317
- posFile: flag("pos-file"))
317
+ posFile: flag("pos-file"), tagOnly: args.contains("--tag-only"),
318
+ rest: flag("rest").flatMap { TimeInterval($0) } ?? 0)
318
319
 
319
320
  case "notify":
320
321
  // A banner under AgentX Helper's name and icon. Exit 2 means macOS has
@@ -269,7 +269,8 @@ enum AgentClient {
269
269
  }
270
270
 
271
271
  /// `handsFree`: the microphone had opened by itself, no key held.
272
- static func ask(_ message: String, agent: String, handsFree: Bool = false) async throws -> Answer {
272
+ /// `request`: the open-requests row on the daemon this answers (#1455).
273
+ static func ask(_ message: String, agent: String, handsFree: Bool = false, request: String? = nil) async throws -> Answer {
273
274
  var req = URLRequest(url: URL(string: "\(Config.daemonURL)/ask")!)
274
275
  req.httpMethod = "POST"
275
276
  // An agent turn routinely takes minutes. The default 60s would cut
@@ -280,9 +281,16 @@ enum AgentClient {
280
281
  // No agent known: the daemon answers with its default agent.
281
282
  if !agent.isEmpty { payload["agent"] = agent }
282
283
  if handsFree { payload["handsFree"] = true }
284
+ if let request { payload["request"] = request }
283
285
  req.httpBody = try JSONSerialization.data(withJSONObject: payload)
284
286
 
285
287
  let (data, response) = try await URLSession.shared.data(for: req)
288
+ return try answer(from: data, status: (response as? HTTPURLResponse)?.statusCode)
289
+ }
290
+
291
+ /// An /ask reply as the app uses it. Also reads the reply the daemon
292
+ /// kept for an open request (GET /voice/requests/:id).
293
+ static func answer(from data: Data, status: Int?) throws -> Answer {
286
294
  struct UiButton: Decodable { let label: String; let url: String }
287
295
  struct UiMedia: Decodable { let type: String; let url: String; let caption: String? }
288
296
  struct Ui: Decodable { let buttons: [UiButton]?; let media: UiMedia? }
@@ -309,15 +317,15 @@ enum AgentClient {
309
317
  // speakable explanation into `text`. Falling through to the error
310
318
  // path here is what made "she is still working" sound like "that
311
319
  // didn't work".
312
- if let http = response as? HTTPURLResponse, http.statusCode == 202,
320
+ if status == 202,
313
321
  let queuedText = reply?.text, !queuedText.isEmpty {
314
322
  return Answer(text: queuedText, written: nil, buttons: [], imageURL: nil,
315
323
  durationMs: reply?.duration, agentID: reply?.agentId, voice: voice)
316
324
  }
317
325
 
318
- if let http = response as? HTTPURLResponse, !(200..<300).contains(http.statusCode) {
326
+ if let status, !(200..<300).contains(status) {
319
327
  let detail = reply?.error ?? String(data: data.prefix(200), encoding: .utf8) ?? ""
320
- throw VoiceError.api("daemon HTTP \(http.statusCode): \(detail)")
328
+ throw VoiceError.api("daemon HTTP \(status): \(detail)")
321
329
  }
322
330
  if let err = reply?.error, !err.isEmpty { throw VoiceError.api(err) }
323
331
  guard let text = reply?.text ?? reply?.full, !text.isEmpty else {
@@ -337,4 +345,99 @@ enum AgentClient {
337
345
  durationMs: reply?.duration, agentID: reply?.agentId, voice: voice,
338
346
  presenceMode: reply?.presence?.mode)
339
347
  }
348
+
349
+ // MARK: Open requests
350
+ //
351
+ // The open-requests list is kept by the daemon (#1455), so it survives
352
+ // a restart and heard on one client is heard on all. See
353
+ // src/daemon/voice-requests-api.ts. None of these throw: without the
354
+ // daemon the app keeps its own list as before.
355
+
356
+ private struct RemoteRow: Decodable {
357
+ let id: String
358
+ let agentId: String
359
+ let question: String
360
+ let state: String
361
+ let sentAt: Double
362
+ let since: Double
363
+ let heard: Bool
364
+ let error: String?
365
+
366
+ var remote: OpenRequests.Remote {
367
+ OpenRequests.Remote(key: id, agentID: agentId, question: question,
368
+ sentAt: Date(timeIntervalSince1970: sentAt / 1000),
369
+ since: Date(timeIntervalSince1970: since / 1000),
370
+ state: state, heard: heard, error: error)
371
+ }
372
+ }
373
+
374
+ /// A new row on the daemon: its id, or nil when the daemon has none.
375
+ static func openRequest(agentID: String, question: String, waiting: Bool) async -> String? {
376
+ struct Reply: Decodable { let request: RemoteRow? }
377
+ guard let (data, _) = try? await post("/voice/requests",
378
+ ["agentId": agentID, "question": question, "waiting": waiting], timeout: 3)
379
+ else { return nil }
380
+ return (try? JSONDecoder().decode(Reply.self, from: data))?.request?.id
381
+ }
382
+
383
+ /// A follow-up continues the row `key` on the daemon: its words now,
384
+ /// not heard.
385
+ static func continueRequest(_ key: String, question: String, waiting: Bool) async {
386
+ _ = try? await post("/voice/requests/\(key)/continue", ["question": question, "waiting": waiting], timeout: 3)
387
+ }
388
+
389
+ /// What reading the daemon's list gave.
390
+ enum RequestsRead {
391
+ case rows([OpenRequests.Remote])
392
+ /// It answered, but keeps no list (older than it, or no SQLite).
393
+ case noList
394
+ /// It did not answer at all.
395
+ case unreachable
396
+ }
397
+
398
+ /// The daemon's open rows.
399
+ static func openRequests() async -> RequestsRead {
400
+ struct Reply: Decodable { let requests: [RemoteRow] }
401
+ guard let url = URL(string: "\(Config.daemonURL)/voice/requests") else { return .unreachable }
402
+ var req = URLRequest(url: url)
403
+ req.timeoutInterval = 3
404
+ guard let (data, response) = try? await URLSession.shared.data(for: req) else { return .unreachable }
405
+ guard (response as? HTTPURLResponse)?.statusCode == 200,
406
+ let rows = (try? JSONDecoder().decode(Reply.self, from: data))?.requests else { return .noList }
407
+ return .rows(rows.map(\.remote))
408
+ }
409
+
410
+ /// The answer the daemon kept for a row, for one the app did not ask
411
+ /// itself (found on the daemon after a restart).
412
+ static func requestAnswer(_ key: String) async -> Answer? {
413
+ guard let url = URL(string: "\(Config.daemonURL)/voice/requests/\(key)") else { return nil }
414
+ var req = URLRequest(url: url)
415
+ req.timeoutInterval = 5
416
+ guard let (data, response) = try? await URLSession.shared.data(for: req),
417
+ (response as? HTTPURLResponse)?.statusCode == 200,
418
+ let obj = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
419
+ let reply = obj["reply"] as? [String: Any],
420
+ let replyData = try? JSONSerialization.data(withJSONObject: reply) else { return nil }
421
+ return try? answer(from: replyData, status: 200)
422
+ }
423
+
424
+ /// Played or opened: heard on every client.
425
+ static func requestHeard(_ key: String) async {
426
+ _ = try? await post("/voice/requests/\(key)/heard", [:], timeout: 3)
427
+ }
428
+
429
+ /// The row leaves the list; `stop` also stops its agent's turn.
430
+ static func closeRequest(_ key: String, stop: Bool) async {
431
+ _ = try? await post("/voice/requests/\(key)/close", ["stop": stop], timeout: 5)
432
+ }
433
+
434
+ /// Undo a close.
435
+ static func reopenRequest(_ key: String) async {
436
+ _ = try? await post("/voice/requests/\(key)/reopen", [:], timeout: 3)
437
+ }
438
+
439
+ /// "Close heard": every heard answer and every failure.
440
+ static func closeHeardRequests() async {
441
+ _ = try? await post("/voice/requests/close-heard", [:], timeout: 3)
442
+ }
340
443
  }
@@ -43,15 +43,6 @@ enum Config {
43
43
  set { UserDefaults.standard.set(newValue, forKey: "playMode") }
44
44
  }
45
45
 
46
- /// "Play answers at once" in the menu: an answer plays as soon as it is
47
- /// back, as before #1455. Off by default: it waits as "not heard" in the
48
- /// open-requests list until picked. A UI choice for now; the setting in
49
- /// agentx.json comes with the Settings window's Answers group.
50
- static var playAnswersAtOnce: Bool {
51
- get { UserDefaults.standard.bool(forKey: "playAnswersAtOnce") }
52
- set { UserDefaults.standard.set(newValue, forKey: "playAnswersAtOnce") }
53
- }
54
-
55
46
  /// Where the pill was last dragged to (its bottom-left corner, in
56
47
  /// screen points). Nil: the default corner.
57
48
  static var pillOrigin: CGPoint? {
@@ -249,7 +249,8 @@ final class HistoryWindow: NSObject {
249
249
  let store = HistoryStore()
250
250
  private var window: NSWindow?
251
251
 
252
- func show() {
252
+ /// `agent`: open on that agent's conversations; nil keeps the filter.
253
+ func show(agent: String? = nil) {
253
254
  if window == nil {
254
255
  let w = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 860, height: 560),
255
256
  styleMask: [.titled, .closable, .miniaturizable, .resizable],
@@ -261,7 +262,7 @@ final class HistoryWindow: NSObject {
261
262
  window = w
262
263
  }
263
264
  store.agents = []
264
- store.reload()
265
+ if let agent, store.agent != agent { store.agent = agent } else { store.reload() }
265
266
  NSApp.activate(ignoringOtherApps: true)
266
267
  window?.makeKeyAndOrderFront(nil)
267
268
  }