agentix-cli 0.100.0 → 0.101.1
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/apps/mac-voice/Sources/AgentXVoice/BubbleMotion.swift +36 -0
- package/apps/mac-voice/Sources/AgentXVoice/Character.swift +21 -7
- package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +30 -9
- package/apps/mac-voice/Sources/AgentXVoice/PanelAnswer.swift +13 -5
- package/apps/mac-voice/Sources/AgentXVoice/PanelBubble.swift +37 -0
- package/apps/mac-voice/Sources/AgentXVoice/PillPlacement.swift +23 -3
- package/apps/mac-voice/Sources/AgentXVoice/SettingsWindow.swift +1 -1
- package/apps/mac-voice/Sources/AgentXVoice/Surface.swift +13 -0
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +2 -2
- package/dist/{App-XLQDP26J.js → App-EYUDDF6K.js} +2 -2
- package/dist/{ChatApp-DRDUXZ66.js → ChatApp-F5LZLBI3.js} +2 -2
- package/dist/{agent-QHM3J2XS.js → agent-XF3BWMOB.js} +2 -2
- package/dist/{board-dashboard-R6ZTCTSI.js → board-dashboard-TVSOWW32.js} +4 -4
- package/dist/{chunk-DRUEPGLP.js → chunk-5UO6BBDG.js} +2 -2
- package/dist/{chunk-S2GPUSBU.js → chunk-AYNZAOJN.js} +2 -2
- package/dist/chunk-ECM2QEXF.js +54 -0
- package/dist/chunk-ECM2QEXF.js.map +1 -0
- package/dist/{chunk-J64VIHL5.js → chunk-EEZI2K7S.js} +2 -2
- package/dist/{chunk-BERHVF3T.js → chunk-EXPIKLUN.js} +2 -2
- package/dist/{chunk-6BZMRVKJ.js → chunk-GOPJG2RG.js} +177 -177
- package/dist/chunk-GOPJG2RG.js.map +1 -0
- package/dist/{chunk-Z4FY64BS.js → chunk-GSFB46YC.js} +2 -2
- package/dist/{chunk-OFVMUBIP.js → chunk-HMDM5MCR.js} +2 -2
- package/dist/{chunk-SJMOZY7Y.js → chunk-HQJW3BC5.js} +2 -2
- package/dist/{chunk-B32A6OOY.js → chunk-MWLX3QCD.js} +47 -47
- package/dist/chunk-MWLX3QCD.js.map +1 -0
- package/dist/{chunk-VBFXUZTY.js → chunk-N57ES35J.js} +2 -2
- package/dist/{chunk-GJ5EJVMZ.js → chunk-PYCTWI2I.js} +2 -2
- package/dist/{chunk-IQJ7UZVV.js → chunk-QRD3ZG27.js} +2 -2
- package/dist/{chunk-DXJRMPGH.js → chunk-RWSCQMLD.js} +2 -2
- package/dist/{chunk-YYCFI4VP.js → chunk-S337S2M7.js} +2 -2
- package/dist/{chunk-BHKWXFJD.js → chunk-TXFIMVVF.js} +5 -5
- package/dist/{chunk-LXJGLNVG.js → chunk-V6W3FFW7.js} +2 -2
- package/dist/{chunk-4BCAH7XI.js → chunk-XO55WKCX.js} +2 -2
- package/dist/{chunk-J4JVKVEK.js → chunk-Y6POV2X5.js} +2 -2
- package/dist/{chunk-BTLW2RML.js → chunk-YOCQ2MWL.js} +2 -2
- package/dist/{chunk-JZJ7AZJD.js → chunk-ZJXDBVBT.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-BLUCLNIS.js → client-526OCGWD.js} +2 -2
- package/dist/config-HCJ5NZW5.js +2 -0
- package/dist/config-mutator-PGR2OGWC.js +2 -0
- package/dist/{doctor-XGQW5SMD.js → doctor-AC5ONEO2.js} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/{program-CH5QSA7K.js → program-2G53UFIU.js} +16 -16
- package/dist/program-2G53UFIU.js.map +1 -0
- package/dist/{promote-K5LP5Q6Z.js → promote-CNKIINYK.js} +2 -2
- package/dist/{query-LHXSINM2.js → query-A2N2LIR7.js} +2 -2
- package/dist/{registry-OQUO6NCW.js → registry-REKWHOHS.js} +2 -2
- package/dist/{request-planner-TW5OCKTF.js → request-planner-MS5BS6HY.js} +2 -2
- package/dist/{review-candidates-EFELFOSY.js → review-candidates-2F4QK6QQ.js} +2 -2
- package/dist/{routing-TSRZLD7B.js → routing-SU5Q4IPM.js} +2 -2
- package/dist/schedule-tool-24KHZY2Z.js +2 -0
- package/dist/scheduler-ALDZOUKJ.js +2 -0
- package/dist/{seat-NIPWHLKC.js → seat-PZBFMYQL.js} +2 -2
- package/dist/{select-UAKDLN76.js → select-D3XOFXA5.js} +2 -2
- package/dist/{set-enabled-74DLXMSM.js → set-enabled-DNDRQ3CZ.js} +2 -2
- package/dist/{tool-TEGHFORD.js → tool-FB6SPVIS.js} +2 -2
- package/dist/{tool-CEBL57UW.js → tool-RRGOHJW6.js} +2 -2
- package/dist/wiki-3DH2QYTX.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-6BZMRVKJ.js.map +0 -1
- package/dist/chunk-B32A6OOY.js.map +0 -1
- package/dist/chunk-JREA25GJ.js +0 -54
- package/dist/chunk-JREA25GJ.js.map +0 -1
- package/dist/config-ZUMI4IY4.js +0 -2
- package/dist/config-mutator-S3CD2IWQ.js +0 -2
- package/dist/program-CH5QSA7K.js.map +0 -1
- package/dist/schedule-tool-JUHRVU5D.js +0 -2
- package/dist/scheduler-EHJPTULN.js +0 -2
- package/dist/wiki-WOK4SCB7.js +0 -2
- /package/dist/{App-XLQDP26J.js.map → App-EYUDDF6K.js.map} +0 -0
- /package/dist/{ChatApp-DRDUXZ66.js.map → ChatApp-F5LZLBI3.js.map} +0 -0
- /package/dist/{agent-QHM3J2XS.js.map → agent-XF3BWMOB.js.map} +0 -0
- /package/dist/{board-dashboard-R6ZTCTSI.js.map → board-dashboard-TVSOWW32.js.map} +0 -0
- /package/dist/{chunk-DRUEPGLP.js.map → chunk-5UO6BBDG.js.map} +0 -0
- /package/dist/{chunk-S2GPUSBU.js.map → chunk-AYNZAOJN.js.map} +0 -0
- /package/dist/{chunk-J64VIHL5.js.map → chunk-EEZI2K7S.js.map} +0 -0
- /package/dist/{chunk-BERHVF3T.js.map → chunk-EXPIKLUN.js.map} +0 -0
- /package/dist/{chunk-Z4FY64BS.js.map → chunk-GSFB46YC.js.map} +0 -0
- /package/dist/{chunk-OFVMUBIP.js.map → chunk-HMDM5MCR.js.map} +0 -0
- /package/dist/{chunk-SJMOZY7Y.js.map → chunk-HQJW3BC5.js.map} +0 -0
- /package/dist/{chunk-VBFXUZTY.js.map → chunk-N57ES35J.js.map} +0 -0
- /package/dist/{chunk-GJ5EJVMZ.js.map → chunk-PYCTWI2I.js.map} +0 -0
- /package/dist/{chunk-IQJ7UZVV.js.map → chunk-QRD3ZG27.js.map} +0 -0
- /package/dist/{chunk-DXJRMPGH.js.map → chunk-RWSCQMLD.js.map} +0 -0
- /package/dist/{chunk-YYCFI4VP.js.map → chunk-S337S2M7.js.map} +0 -0
- /package/dist/{chunk-BHKWXFJD.js.map → chunk-TXFIMVVF.js.map} +0 -0
- /package/dist/{chunk-LXJGLNVG.js.map → chunk-V6W3FFW7.js.map} +0 -0
- /package/dist/{chunk-4BCAH7XI.js.map → chunk-XO55WKCX.js.map} +0 -0
- /package/dist/{chunk-J4JVKVEK.js.map → chunk-Y6POV2X5.js.map} +0 -0
- /package/dist/{chunk-BTLW2RML.js.map → chunk-YOCQ2MWL.js.map} +0 -0
- /package/dist/{chunk-JZJ7AZJD.js.map → chunk-ZJXDBVBT.js.map} +0 -0
- /package/dist/{client-BLUCLNIS.js.map → client-526OCGWD.js.map} +0 -0
- /package/dist/{config-ZUMI4IY4.js.map → config-HCJ5NZW5.js.map} +0 -0
- /package/dist/{config-mutator-S3CD2IWQ.js.map → config-mutator-PGR2OGWC.js.map} +0 -0
- /package/dist/{doctor-XGQW5SMD.js.map → doctor-AC5ONEO2.js.map} +0 -0
- /package/dist/{promote-K5LP5Q6Z.js.map → promote-CNKIINYK.js.map} +0 -0
- /package/dist/{query-LHXSINM2.js.map → query-A2N2LIR7.js.map} +0 -0
- /package/dist/{registry-OQUO6NCW.js.map → registry-REKWHOHS.js.map} +0 -0
- /package/dist/{request-planner-TW5OCKTF.js.map → request-planner-MS5BS6HY.js.map} +0 -0
- /package/dist/{review-candidates-EFELFOSY.js.map → review-candidates-2F4QK6QQ.js.map} +0 -0
- /package/dist/{routing-TSRZLD7B.js.map → routing-SU5Q4IPM.js.map} +0 -0
- /package/dist/{schedule-tool-JUHRVU5D.js.map → schedule-tool-24KHZY2Z.js.map} +0 -0
- /package/dist/{scheduler-EHJPTULN.js.map → scheduler-ALDZOUKJ.js.map} +0 -0
- /package/dist/{seat-NIPWHLKC.js.map → seat-PZBFMYQL.js.map} +0 -0
- /package/dist/{select-UAKDLN76.js.map → select-D3XOFXA5.js.map} +0 -0
- /package/dist/{set-enabled-74DLXMSM.js.map → set-enabled-DNDRQ3CZ.js.map} +0 -0
- /package/dist/{tool-TEGHFORD.js.map → tool-FB6SPVIS.js.map} +0 -0
- /package/dist/{tool-CEBL57UW.js.map → tool-RRGOHJW6.js.map} +0 -0
- /package/dist/{wiki-WOK4SCB7.js.map → wiki-3DH2QYTX.js.map} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// When the character's bubble is reduced to its three dots (#554): while
|
|
4
|
+
/// the character moves, so a wide bubble is not carried across the screen.
|
|
5
|
+
/// Stepped once a frame. Foundation only, so the tests can run it without
|
|
6
|
+
/// a window.
|
|
7
|
+
struct BubbleMotion {
|
|
8
|
+
/// Seconds it moves before the bubble reduces, and rests before the
|
|
9
|
+
/// bubble grows back: a short move changes nothing, and two moves
|
|
10
|
+
/// close together are one. Then the seconds the change itself takes.
|
|
11
|
+
static let after = 0.15, rest = 0.6, ease = 0.25
|
|
12
|
+
|
|
13
|
+
private(set) var reduced = false
|
|
14
|
+
private var moving = false
|
|
15
|
+
private var since = 0.0
|
|
16
|
+
private var last = 0.0
|
|
17
|
+
private var amount = 0.0
|
|
18
|
+
|
|
19
|
+
/// One frame: 0 the full bubble … 1 the dots, eased. `holds`: the
|
|
20
|
+
/// bubble has something to read or to use (an answer, an error, the
|
|
21
|
+
/// call buttons), which is never reduced.
|
|
22
|
+
mutating func step(now: Double, moving: Bool, holds: Bool) -> Double {
|
|
23
|
+
if moving != self.moving { self.moving = moving; since = now }
|
|
24
|
+
let dt = min(max(now - last, 0), 0.1)
|
|
25
|
+
last = now
|
|
26
|
+
if holds {
|
|
27
|
+
reduced = false
|
|
28
|
+
amount = 0
|
|
29
|
+
} else if moving != reduced, now - since >= (moving ? Self.after : Self.rest) {
|
|
30
|
+
reduced = moving
|
|
31
|
+
}
|
|
32
|
+
let step = dt / Self.ease
|
|
33
|
+
amount += min(max((reduced ? 1 : 0) - amount, -step), step)
|
|
34
|
+
return amount * amount * (3 - 2 * amount)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -41,10 +41,12 @@ final class CharacterHost {
|
|
|
41
41
|
/// Where the pointer is, in screen coordinates.
|
|
42
42
|
var pointerSource: () -> NSPoint = { NSEvent.mouseLocation }
|
|
43
43
|
/// Its speech bubble (#491), the pill: told every frame where the
|
|
44
|
-
/// character's head is
|
|
45
|
-
///
|
|
46
|
-
|
|
44
|
+
/// character's head is, on which screen, and how far reduced to its
|
|
45
|
+
/// dots it is (0…1), it answers with where the bubble is, or nil
|
|
46
|
+
/// while it is hidden. Set by the app.
|
|
47
|
+
var bubble: ((NSPoint, NSRect, CGFloat) -> NSRect?)?
|
|
47
48
|
private var bubbleFrame: NSRect?
|
|
49
|
+
private var motion = BubbleMotion()
|
|
48
50
|
/// What stands on its line (#539): the sides of the windows there,
|
|
49
51
|
/// read once a second while it may stroll and play mode is ticked.
|
|
50
52
|
private var edges: [Double] = []
|
|
@@ -78,7 +80,8 @@ final class CharacterHost {
|
|
|
78
80
|
window = NSPanel(contentRect: NSRect(origin: .zero, size: Self.size),
|
|
79
81
|
styleMask: [.borderless, .nonactivatingPanel], backing: .buffered, defer: false)
|
|
80
82
|
window.isFloatingPanel = true
|
|
81
|
-
|
|
83
|
+
// One above its bubble, which never hides it (#554).
|
|
84
|
+
window.level = NSWindow.Level(rawValue: NSWindow.Level.floating.rawValue + 1)
|
|
82
85
|
window.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary, .stationary]
|
|
83
86
|
window.isOpaque = false
|
|
84
87
|
window.backgroundColor = .clear
|
|
@@ -260,9 +263,20 @@ final class CharacterHost {
|
|
|
260
263
|
let origin = NSPoint(x: (CGFloat(frame.x) - Self.size.width / 2).rounded(), y: (rest.y - Self.ground).rounded())
|
|
261
264
|
if window.frame.origin != origin { window.setFrameOrigin(origin) }
|
|
262
265
|
body = NSRect(x: CGFloat(frame.x) - Self.diameter / 2, y: rest.y, width: Self.diameter, height: Self.head)
|
|
263
|
-
// The bubble goes with the window, so the two move as one.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
// The bubble goes with the window, so the two move as one. It
|
|
267
|
+
// stays above the top of the body, a jump included, as far as the
|
|
268
|
+
// screen has room, and is reduced to its dots while it moves (#554).
|
|
269
|
+
let top = CGFloat(frame.pose.lift + 100 * frame.pose.sy) * Self.diameter / 100
|
|
270
|
+
let room = max(visible.maxY - rest.y - PillPlacement.tail - Panel.size.height, Self.head)
|
|
271
|
+
let head = min(max(top + 2 - PillPlacement.tail, Self.head), room)
|
|
272
|
+
let moving = carried != nil || abs(sim.speed) > 8 || rest.y != spot.place.y || head > Self.head
|
|
273
|
+
if still { motion = BubbleMotion() }
|
|
274
|
+
let small = still ? 0 : motion.step(now: now, moving: moving, holds: bubbleShows?() ?? false)
|
|
275
|
+
let at = NSPoint(x: origin.x + Self.size.width / 2, y: origin.y + Self.ground + head)
|
|
276
|
+
bubbleFrame = bubble?(at, visible, CGFloat(small))
|
|
277
|
+
// Its tail, unless the bubble had to go beside it.
|
|
278
|
+
let above = bubbleFrame.map { $0.minY >= at.y && $0.minX < at.x && at.x < $0.maxX } ?? false
|
|
279
|
+
view.bubble = above ? bubbleFrame?.offsetBy(dx: -origin.x, dy: -origin.y) : nil
|
|
266
280
|
view.origin = origin.x
|
|
267
281
|
view.shown = frame
|
|
268
282
|
view.needsDisplay = true
|
|
@@ -125,6 +125,11 @@ final class Panel: NSPanel {
|
|
|
125
125
|
/// character's head is, and the screen it is on.
|
|
126
126
|
private(set) var bubble: (head: NSPoint, visible: NSRect)?
|
|
127
127
|
|
|
128
|
+
/// 0 the full bubble … 1 its three dots, while its character moves
|
|
129
|
+
/// (PanelBubble.swift).
|
|
130
|
+
var small: CGFloat = 0
|
|
131
|
+
let dots = BubbleDots()
|
|
132
|
+
|
|
128
133
|
/// Told of every state rendered, so the menu-bar icon can follow.
|
|
129
134
|
var onRender: ((State) -> Void)?
|
|
130
135
|
|
|
@@ -263,6 +268,10 @@ final class Panel: NSPanel {
|
|
|
263
268
|
separator.isHidden = true
|
|
264
269
|
surface.addSubview(separator)
|
|
265
270
|
surface.addSubview(answer)
|
|
271
|
+
dots.frame = surface.bounds
|
|
272
|
+
dots.autoresizingMask = [.width, .height]
|
|
273
|
+
dots.alphaValue = 0
|
|
274
|
+
surface.addSubview(dots)
|
|
266
275
|
answer.onHeight = { [weak self] height in self?.grow(answerHeight: height) }
|
|
267
276
|
|
|
268
277
|
// The orb, centred 28 points from the left edge; its square is
|
|
@@ -331,7 +340,8 @@ final class Panel: NSPanel {
|
|
|
331
340
|
row.frame = NSRect(x: 0, y: above ? 0 : answerHeight, width: bounds.width, height: h)
|
|
332
341
|
// Reduced, the orb is all there is: in the middle of its circle.
|
|
333
342
|
orb.frame.origin.x = reduced ? (bounds.width - Self.orbFrame) / 2 : 28 - Self.orbFrame / 2
|
|
334
|
-
|
|
343
|
+
// Reduced either way, the row is not laid out: nothing of it shows.
|
|
344
|
+
if reduced || small > 0 { return }
|
|
335
345
|
closeButton.frame.origin.x = bounds.width - 28
|
|
336
346
|
// The mini orbs sit between the words and the close button, and
|
|
337
347
|
// the words give up that room while they show.
|
|
@@ -403,19 +413,24 @@ final class Panel: NSPanel {
|
|
|
403
413
|
}
|
|
404
414
|
|
|
405
415
|
/// The character's speech bubble (#491): the pill sits above `head`,
|
|
406
|
-
/// the top of the character, and goes where it goes, grown or not
|
|
407
|
-
///
|
|
408
|
-
///
|
|
416
|
+
/// the top of the character, and goes where it goes, grown or not,
|
|
417
|
+
/// never over it (#554). `small` of the way reduced to its dots,
|
|
418
|
+
/// unless it has grown into an answer. It is not dragged by itself,
|
|
419
|
+
/// and the place it was dragged to as a pill is kept for the orb look.
|
|
409
420
|
@MainActor
|
|
410
|
-
func attach(head: NSPoint, visible: NSRect) {
|
|
421
|
+
func attach(head: NSPoint, visible: NSRect, small amount: CGFloat = 0) {
|
|
411
422
|
bubble = (head, visible)
|
|
412
423
|
isMovableByWindowBackground = false
|
|
413
424
|
// Growing or collapsing: it catches up on the next frame.
|
|
414
425
|
guard placing == 0 else { return }
|
|
415
|
-
|
|
416
|
-
let
|
|
417
|
-
let
|
|
418
|
-
|
|
426
|
+
shrink(expanded ? 0 : amount)
|
|
427
|
+
let shape = PillPlacement.shrunk(Self.size, small: small)
|
|
428
|
+
let size = expanded ? frame.size : shape.size
|
|
429
|
+
let to = NSRect(origin: PillPlacement.bubble(size: size, head: head, visible: visible, reach: shape.reach), size: size)
|
|
430
|
+
guard to != frame else { return }
|
|
431
|
+
placing += 1
|
|
432
|
+
setFrame(to, display: true)
|
|
433
|
+
placing -= 1
|
|
419
434
|
}
|
|
420
435
|
|
|
421
436
|
/// The orb look again: a pill of its own, back where it was left.
|
|
@@ -424,6 +439,12 @@ final class Panel: NSPanel {
|
|
|
424
439
|
guard bubble != nil else { return }
|
|
425
440
|
bubble = nil
|
|
426
441
|
isMovableByWindowBackground = true
|
|
442
|
+
if small > 0 {
|
|
443
|
+
shrink(0)
|
|
444
|
+
placing += 1
|
|
445
|
+
setContentSize(Self.size)
|
|
446
|
+
placing -= 1
|
|
447
|
+
}
|
|
427
448
|
restorePosition()
|
|
428
449
|
}
|
|
429
450
|
|
|
@@ -25,11 +25,15 @@ extension Panel {
|
|
|
25
25
|
guard !dismissed else { return }
|
|
26
26
|
// An answer to read, or one that asks: the full pill opens for it.
|
|
27
27
|
setReduced(false)
|
|
28
|
+
shrink(0)
|
|
28
29
|
let pill = collapsedFrame()
|
|
29
|
-
guard let visible = visibleFrame(for: pill) else { return }
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
guard let visible = bubble?.visible ?? visibleFrame(for: pill) else { return }
|
|
31
|
+
let size = CGSize(width: Self.expandedWidth, height: min(Self.size.height + min(answerHeight, cardMaxHeight), visible.height))
|
|
32
|
+
// The character's bubble opens above it, or beside it: never over it.
|
|
33
|
+
let spot = bubble.map {
|
|
34
|
+
PillPlacement.Expanded(frame: CGRect(origin: PillPlacement.bubble(size: size, head: $0.head, visible: visible), size: size),
|
|
35
|
+
above: true, alignRight: true)
|
|
36
|
+
} ?? PillPlacement.expanded(size: size, pill: pill, visible: visible)
|
|
33
37
|
if !expanded {
|
|
34
38
|
growth = (spot.above, spot.alignRight)
|
|
35
39
|
expanded = true
|
|
@@ -50,7 +54,11 @@ extension Panel {
|
|
|
50
54
|
collapseTimer = nil
|
|
51
55
|
guard expanded else { return }
|
|
52
56
|
var pill = collapsedFrame()
|
|
53
|
-
if let
|
|
57
|
+
if let bubble {
|
|
58
|
+
pill.origin = PillPlacement.bubble(size: Self.size, head: bubble.head, visible: bubble.visible)
|
|
59
|
+
} else if let visible = visibleFrame(for: pill) {
|
|
60
|
+
pill = PillPlacement.inside(pill, visible)
|
|
61
|
+
}
|
|
54
62
|
expanded = false
|
|
55
63
|
animate(to: pill, animated: animated) { [weak self] in
|
|
56
64
|
guard let self, !self.expanded else { return }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import AppKit
|
|
2
|
+
|
|
3
|
+
/// The bubble while its character moves (#554): reduced to three dots in
|
|
4
|
+
/// the smallest shape that holds them, so the character is not carried
|
|
5
|
+
/// across the screen under a wide pill. The dots say it is still there,
|
|
6
|
+
/// listening or answering; the words come back when the character rests.
|
|
7
|
+
/// When that is, is in BubbleMotion.swift; the sizes in PillPlacement.
|
|
8
|
+
extension Panel {
|
|
9
|
+
/// `amount` of the way from the pill (0) to its dots (1): the words
|
|
10
|
+
/// fade out, then the dots fade in, and the shape follows. The frame
|
|
11
|
+
/// is set by `attach`, with the place.
|
|
12
|
+
@MainActor
|
|
13
|
+
func shrink(_ amount: CGFloat) {
|
|
14
|
+
guard amount != small else { return }
|
|
15
|
+
small = amount
|
|
16
|
+
row.alphaValue = max(1 - 2 * amount, 0)
|
|
17
|
+
dots.alphaValue = max(2 * amount - 1, 0)
|
|
18
|
+
(contentView as? Surface)?.shape(size: amount > 0 ? PillPlacement.shrunk(Self.size, small: amount).size : nil)
|
|
19
|
+
invalidateShadow()
|
|
20
|
+
// The row was not laid out while reduced, and the frame may already
|
|
21
|
+
// be the full pill's: nothing else would lay it out again.
|
|
22
|
+
if amount == 0, let content = contentView { layoutContent(content.bounds) }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// Three dots, in the middle of the bubble.
|
|
27
|
+
final class BubbleDots: NSView {
|
|
28
|
+
override func draw(_ dirtyRect: NSRect) {
|
|
29
|
+
NSColor.secondaryLabelColor.setFill()
|
|
30
|
+
for i in -1...1 {
|
|
31
|
+
NSBezierPath(ovalIn: NSRect(x: bounds.midX + CGFloat(i) * 10 - 2.5, y: bounds.midY - 2.5, width: 5, height: 5)).fill()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Clicks go through to the pill: a click on the dots talks.
|
|
36
|
+
override func hitTest(_ point: NSPoint) -> NSView? { nil }
|
|
37
|
+
}
|
|
@@ -86,9 +86,29 @@ enum PillPlacement {
|
|
|
86
86
|
|
|
87
87
|
/// The pill as the character's speech bubble (#491): above `head`,
|
|
88
88
|
/// the top of the character, most of it to the left, kept on screen.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
/// Too tall for the room above (an answer, high on a screen): beside
|
|
90
|
+
/// the character instead, clear of its marks, on the left or with no
|
|
91
|
+
/// room there on the right. Never over it (#554).
|
|
92
|
+
static func bubble(size: CGSize, head: CGPoint, visible: CGRect, reach: CGFloat = bubbleReach) -> CGPoint {
|
|
93
|
+
var frame = CGRect(x: head.x + reach - size.width, y: head.y + tail, width: size.width, height: size.height)
|
|
94
|
+
if frame.maxY > visible.maxY {
|
|
95
|
+
let left = head.x - bubbleReach - size.width
|
|
96
|
+
frame.origin.x = left >= visible.minX ? left : head.x + bubbleReach
|
|
97
|
+
}
|
|
98
|
+
return inside(frame, visible).origin
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// The bubble while its character moves (#554): three dots in the
|
|
102
|
+
/// smallest shape that holds them, in the middle above its head.
|
|
103
|
+
static let dots = CGSize(width: 48, height: 28)
|
|
104
|
+
|
|
105
|
+
/// The bubble `small` of the way (0…1) from the pill to its dots: its
|
|
106
|
+
/// size, and how far it reaches to the right of the character's middle.
|
|
107
|
+
static func shrunk(_ full: CGSize, small: CGFloat) -> (size: CGSize, reach: CGFloat) {
|
|
108
|
+
let p = min(max(small, 0), 1)
|
|
109
|
+
return (CGSize(width: (full.width + (dots.width - full.width) * p).rounded(),
|
|
110
|
+
height: (full.height + (dots.height - full.height) * p).rounded()),
|
|
111
|
+
bubbleReach + (dots.width / 2 - bubbleReach) * p)
|
|
92
112
|
}
|
|
93
113
|
|
|
94
114
|
/// How close the middle of the character comes to the left edge of
|
|
@@ -336,7 +336,7 @@ private struct AgentForm: View {
|
|
|
336
336
|
set: { agent.color = $0.hex; agent.colorSet = true })
|
|
337
337
|
let footer = agent.colorSet
|
|
338
338
|
? "Hold the shortcut and speak to ask this agent without changing who is ticked in the menu. The colour also paints this agent's pointer, and picks the orb's palette unless you choose one."
|
|
339
|
-
: "Hold the shortcut and speak to ask this agent without changing who is ticked in the menu. The colour comes from the agent's id until you pick one
|
|
339
|
+
: "Hold the shortcut and speak to ask this agent without changing who is ticked in the menu. The colour comes from the agent's id until you pick one. A colour you pick also picks the orb's palette unless you choose one."
|
|
340
340
|
return Section {
|
|
341
341
|
HotkeyField(title: "Ask with shortcut", value: $agent.voice.hotkey, optional: true, model: model, id: "agent.\(agent.id)")
|
|
342
342
|
HStack {
|
|
@@ -69,6 +69,19 @@ final class Surface: NSVisualEffectView {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/// The pill's own shape at exactly `size`, for a bubble smaller than
|
|
73
|
+
/// its corners: the stretchable mask cannot draw that one either.
|
|
74
|
+
func shape(size: NSSize?) {
|
|
75
|
+
guard let size else { shape(circle: nil); return }
|
|
76
|
+
let radius = min(Brand.Radius.lg, size.height / 2)
|
|
77
|
+
layer?.cornerRadius = radius
|
|
78
|
+
maskImage = NSImage(size: size, flipped: false) { rect in
|
|
79
|
+
NSColor.black.setFill()
|
|
80
|
+
NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius).fill()
|
|
81
|
+
return true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
|
73
86
|
super.resizeSubviews(withOldSize: oldSize)
|
|
74
87
|
layoutContent?(bounds)
|
|
@@ -388,9 +388,9 @@ final class App: NSObject, NSApplicationDelegate {
|
|
|
388
388
|
character.levelSource = { [weak self] in self?.recorder.level ?? 0 }
|
|
389
389
|
// The pill is the character's speech bubble: it goes where the
|
|
390
390
|
// character goes.
|
|
391
|
-
character.bubble = { [weak self] head, visible in
|
|
391
|
+
character.bubble = { [weak self] head, visible, small in
|
|
392
392
|
guard let panel = self?.panel else { return nil }
|
|
393
|
-
panel.attach(head: head, visible: visible)
|
|
393
|
+
panel.attach(head: head, visible: visible, small: small)
|
|
394
394
|
return panel.isVisible ? panel.frame : nil
|
|
395
395
|
}
|
|
396
396
|
character.bubbleShows = { [weak self] in self?.panel.holdsSomething ?? false }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as F,b as L,c as U,d as N,e as O,f as H,g as j}from"./chunk-U2CKL755.js";import{b as B,c as D,d as A,e as P,g as M}from"./chunk-
|
|
1
|
+
import{a as F,b as L,c as U,d as N,e as O,f as H,g as j}from"./chunk-U2CKL755.js";import{b as B,c as D,d as A,e as P,g as M}from"./chunk-PYCTWI2I.js";import"./chunk-ECM2QEXF.js";import"./chunk-RJ7DASOU.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useEffect as R,useReducer as V,useRef as G}from"react";import{Box as i,Text as o,useApp as W,useInput as J}from"ink";import{randomUUID as z}from"crypto";async function*q(e){let r=[];e.type&&r.push(`type=${encodeURIComponent(e.type)}`);let t=`${e.baseUrl.replace(/\/+$/,"")}/events${r.length?`?${r.join("&")}`:""}`,n={Accept:"text/event-stream"};e.token&&(n.Authorization=`Bearer ${e.token}`);let s=await fetch(t,{headers:n,signal:e.signal});if(!s.ok||!s.body)throw new Error(`SSE connect failed: HTTP ${s.status}`);let u=s.body.getReader(),p=new TextDecoder,y="";try{for(;;){let{done:f,value:l}=await u.read();if(f)return;y+=p.decode(l,{stream:!0});let d;for(;(d=y.indexOf(`
|
|
2
2
|
|
|
3
3
|
`))>=0;){let h=y.slice(0,d);y=y.slice(d+2);let m=X(h);m&&(yield m)}}}finally{try{u.releaseLock()}catch{}}}function X(e){let r="message",t="";for(let s of e.split(`
|
|
4
4
|
`))s.startsWith("event: ")?r=s.slice(7):s.startsWith("data: ")&&(t=s.slice(6));if(!t)return null;let n;try{n=JSON.parse(t)}catch{n=t}return{event:r,data:n}}import{jsx as a,jsxs as c}from"react/jsx-runtime";function $(e,r){return r<=0||e<0?0:e>=r?r-1:e}function E(){return`tui:${z().slice(0,12)}`}function k(e,r){let t=[...e,r];return t.length>50&&t.splice(0,t.length-50),t}function Y(e,r){switch(r.type){case"agents":return{...e,agents:r.data,cursor:{...e.cursor,agents:$(e.cursor.agents,r.data.length)}};case"processes":return{...e,processes:r.data,cursor:{...e.cursor,processes:$(e.cursor.processes,r.data.length)}};case"crons":return{...e,crons:r.data};case"event":{let t=[r.row,...e.events];t.length>200&&(t.length=200);let n=e.channels;return r.channelTally&&(n=new Map(e.channels),n.set(r.channelTally.channel,r.channelTally)),{...e,events:t,channels:n}}case"connError":return{...e,connError:r.error};case"tick":return{...e,lastTick:Date.now()};case"focus":return{...e,focus:r.pane};case"cursor":{let t=r.pane==="agents"?e.agents.length:r.pane==="processes"?e.processes.length:e.events.length;return{...e,cursor:{...e.cursor,[r.pane]:$(e.cursor[r.pane]+r.delta,t)}}}case"bottomRight":return{...e,bottomRight:r.pane};case"chatStart":return{...e,chat:{active:!0,agentId:r.agentId,chatId:E(),history:[],text:"",status:"idle",error:null}};case"chatExit":return{...e,chat:{...e.chat,active:!1}};case"chatClear":return{...e,chat:{...e.chat,chatId:E(),history:[],text:"",status:"idle",error:null}};case"chatText":return{...e,chat:{...e.chat,text:r.text}};case"chatSubmitStart":return{...e,chat:{...e.chat,history:k(e.chat.history,r.you),text:"",status:"sending",error:null}};case"chatSubmitDone":return{...e,chat:{...e.chat,history:k(e.chat.history,r.reply),status:"idle",error:null}};case"chatSubmitError":return{...e,chat:{...e.chat,history:k(e.chat.history,{role:"error",text:r.error,at:Date.now()}),status:"idle",error:r.error}};case"chatStreamStart":{let t=k(e.chat.history,r.you),n=k(t,{role:"agent",text:"",at:Date.now(),streaming:!0,tools:[]});return{...e,chat:{...e.chat,history:n,text:"",status:"sending",error:null}}}case"chatStreamDelta":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,text:n.text+r.text}),{...e,chat:{...e.chat,history:t}}}case"chatStreamThinking":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,thinking:(n.thinking??"")+r.text}),{...e,chat:{...e.chat,history:t}}}case"chatStreamTool":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]={...n,tools:[...n.tools??[],{name:r.name,arg:r.arg,error:r.error}]}),{...e,chat:{...e.chat,history:t}}}case"chatStreamEnd":{let t=e.chat.history.slice(),n=t[t.length-1];return n?.role==="agent"&&n.streaming&&(t[t.length-1]=r.error?{...n,streaming:!1,role:"error",text:r.error}:{...n,streaming:!1,elapsedMs:r.elapsedMs,outTokens:r.outTokens}),{...e,chat:{...e.chat,history:t,status:"idle",error:r.error??null}}}case"toast":return{...e,toast:{text:r.text,color:r.color,at:Date.now()}};case"clearToast":return{...e,toast:null}}}var _={agents:[],processes:[],crons:[],events:[],channels:new Map,connError:null,lastTick:0,focus:"agents",cursor:{agents:0,processes:0,events:0},bottomRight:"crons",chat:{active:!1,agentId:null,chatId:E(),history:[],text:"",status:"idle",error:null},toast:null};function be({conn:e,pollMs:r=3e3}){let[t,n]=V(Y,_),{exit:s}=W(),u=G(null),p=G(null),y=t.agents.map(l=>l.id),f=t.chat.active?L(t.chat.text,y,process.cwd()):null;return R(()=>{if(!t.toast)return;let l=setTimeout(()=>n({type:"clearToast"}),3500);return()=>clearTimeout(l)},[t.toast]),J((l,d)=>{if(t.chat.active){if(d.escape){n({type:"chatExit"});return}if(d.ctrl&&l==="l"){n({type:"chatClear"});return}if(d.tab){let m=U(t.chat.text,p,y,process.cwd());m!==null&&n({type:"chatText",text:m});return}if(d.backspace||d.delete){p.current=null,n({type:"chatText",text:t.chat.text.slice(0,-1)});return}if(d.ctrl||d.meta)return;let h=N(l??"",d.return,t.chat.text);if(h.kind==="paste"||h.kind==="type"){p.current=null,n({type:"chatText",text:t.chat.text+h.text});return}if(h.kind==="continue"){n({type:"chatText",text:h.buffer});return}if(h.kind==="submit"){let m=h.text.trim(),g=t.chat.agentId;if(!m||!g||t.chat.status==="sending"){n({type:"chatText",text:""});return}p.current=null;let b=Date.now(),w=t.chat.chatId;n({type:"chatStreamStart",you:{role:"you",text:m,at:b}}),(async()=>{try{let C=await M(e,g,m,{channel:"tui",chatId:w,onText:x=>n({type:"chatStreamDelta",text:x}),onThinking:x=>n({type:"chatStreamThinking",text:x}),onTool:x=>{x.status==="start"&&x.name?n({type:"chatStreamTool",name:x.name,arg:x.arg}):x.status==="result"&&x.error&&n({type:"chatStreamTool",name:x.name??"tool",error:!0})}});n({type:"chatStreamEnd",elapsedMs:Date.now()-b,outTokens:C.usage?.outputTokens,error:C.error})}catch(C){n({type:"chatStreamEnd",elapsedMs:Date.now()-b,error:C?.message||String(C)})}})();return}return}if(l==="q"||d.ctrl&&l==="c"){u.current?.abort(),s();return}if(d.tab){let h=["agents","processes","events"],m=h.indexOf(t.focus);n({type:"focus",pane:h[(m+1)%h.length]});return}if(l==="a"){n({type:"focus",pane:"agents"});return}if(l==="p"){n({type:"focus",pane:"processes"});return}if(l==="e"){n({type:"focus",pane:"events"});return}if(l==="c"){n({type:"bottomRight",pane:t.bottomRight==="crons"?"channels":"crons"});return}if(d.upArrow){n({type:"cursor",pane:t.focus,delta:-1});return}if(d.downArrow){n({type:"cursor",pane:t.focus,delta:1});return}if(d.return&&t.focus==="agents"){let h=t.agents[t.cursor.agents];if(!h){n({type:"toast",text:"no agent selected",color:"yellow"});return}n({type:"chatStart",agentId:h.id});return}if(l==="k"&&t.focus==="processes"){let h=t.processes[t.cursor.processes];if(!h){n({type:"toast",text:"no process selected",color:"yellow"});return}(async()=>{try{await P(e,h.key,"tui"),n({type:"toast",text:`killed ${h.key.agentId}/${h.key.channel}/${h.key.chatId}`,color:"green"})}catch(m){n({type:"toast",text:`kill failed: ${m?.message||m}`,color:"red"})}})();return}}),R(()=>{let l=new AbortController;u.current=l;let d=!1,h=async()=>{try{let[g,b,w]=await Promise.all([B(e,l.signal).catch(()=>[]),D(e,l.signal).catch(()=>[]),A(e,l.signal).catch(()=>[])]);if(d)return;n({type:"agents",data:g}),n({type:"processes",data:b}),n({type:"crons",data:w}),n({type:"tick"}),n({type:"connError",error:null})}catch(g){d||n({type:"connError",error:g?.message||String(g)})}};h();let m=setInterval(h,r);return()=>{d=!0,clearInterval(m),l.abort()}},[e.baseUrl,e.token,r]),R(()=>{let l=!1,d=new AbortController,h=new Map;return(async()=>{let m=500;for(;!l;){try{for await(let g of q({baseUrl:e.baseUrl,token:e.token,signal:d.signal})){let b=ae(g),w;if(g.event==="channel"&&typeof g.data?.channel=="string"){let S=h.get(g.data.channel)??{channel:g.data.channel,inbound:0,outbound:0,lastAt:0,lastPreview:""},C=S.inbound+(g.data.direction==="in"?1:0),x=S.outbound+(g.data.direction==="out"?1:0);w={channel:g.data.channel,inbound:C,outbound:x,lastAt:b.at,lastPreview:(g.data.textPreview||"").slice(0,60)},h.set(g.data.channel,w)}n({type:"event",row:b,channelTally:w}),m=500}}catch(g){if(l)return;n({type:"connError",error:`events: ${g?.message||g}`})}await new Promise(g=>setTimeout(g,m)),m=Math.min(m*2,1e4)}})(),()=>{l=!0,d.abort()}},[e.baseUrl,e.token]),c(i,{flexDirection:"column",width:"100%",children:[a(K,{conn:e,lastTick:t.lastTick,connError:t.connError,chat:t.chat}),c(i,{flexDirection:"row",flexGrow:1,children:[c(i,{flexDirection:"column",width:"50%",children:[a(v,{title:"AGENTS",focused:!t.chat.active&&t.focus==="agents",children:a(Z,{rows:t.agents,cursor:t.cursor.agents,focused:!t.chat.active&&t.focus==="agents",talkingTo:t.chat.active?t.chat.agentId:null})}),a(v,{title:"PROCESSES",focused:!t.chat.active&&t.focus==="processes",children:a(ee,{rows:t.processes,cursor:t.cursor.processes,focused:!t.chat.active&&t.focus==="processes"})})]}),t.chat.active?a(oe,{chat:t.chat,suggest:f,agents:t.agents}):c(i,{flexDirection:"column",width:"50%",children:[a(v,{title:"LIVE EVENTS",focused:t.focus==="events",children:a(ne,{rows:t.events,cursor:t.cursor.events,focused:t.focus==="events"})}),a(v,{title:t.bottomRight==="crons"?"CRONS / SCHEDULES":"CHANNELS",focused:!1,children:t.bottomRight==="crons"?a(te,{rows:t.crons}):a(re,{rows:Array.from(t.channels.values())})})]})]}),a(Q,{focus:t.focus,bottomRight:t.bottomRight,chat:t.chat,toast:t.toast})]})}function K({conn:e,lastTick:r,connError:t,chat:n}){let s=t?c(o,{color:"red",children:["\u25CF ",t]}):r===0?a(o,{color:"yellow",children:"\u25CF connecting\u2026"}):a(o,{color:"green",children:"\u25CF live"}),u=n.active?c(o,{color:"green",bold:!0,children:["CHAT @",n.agentId]}):a(o,{bold:!0,children:"agentx tui"});return c(i,{paddingX:1,justifyContent:"space-between",children:[a(i,{children:u}),a(o,{dimColor:!0,children:e.baseUrl}),a(i,{children:s})]})}function Q({focus:e,bottomRight:r,chat:t,toast:n}){let s=t.active?["[Enter] send","[Esc] exit chat","[Ctrl-L] new session"]:[`[Tab/a/p/e] focus (now: ${e})`,e==="agents"?"[Enter] chat":null,e==="processes"?"[k] kill":null,`[c] ${r==="crons"?"\u2192channels":"\u2192crons"}`,"[\u2191/\u2193] move","[q] quit"].filter(Boolean);return c(i,{paddingX:1,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,justifyContent:"space-between",children:[a(o,{dimColor:!0,children:s.join(" \xB7 ")}),n?a(o,{color:n.color,children:n.text}):a(o,{children:" "})]})}function v({title:e,focused:r,children:t}){return c(i,{flexDirection:"column",width:"100%",borderStyle:r?"double":"single",borderColor:r?"cyan":void 0,paddingX:1,children:[c(o,{bold:!0,color:r?"cyan":"white",children:[e,r?" \u25CF":""]}),a(i,{flexDirection:"column",marginTop:1,children:t})]})}function I(e,r){return e&&r?{inverse:!0}:{}}function Z({rows:e,cursor:r,focused:t,talkingTo:n}){return e.length===0?a(o,{dimColor:!0,children:"no agents"}):a(i,{flexDirection:"column",children:e.slice(0,12).map((s,u)=>{let p=I(t,u===r),y=s.errors>0?"red":s.active>0?"yellow":"green",f=s.id===n;return c(i,{children:[a(o,{...p,color:y,children:"\u25CF"}),c(o,{...p,children:[" ",T(s.name,14)]}),c(o,{...p,children:[T(s.tier,6)," "]}),c(o,{...p,children:[s.active,"/",s.total]}),s.errors>0?c(o,{...p,color:"red",children:[" err=",s.errors]}):null,f?a(o,{color:"green",children:" \u2194 chatting"}):null]},s.id)})})}function ee({rows:e,cursor:r,focused:t}){if(e.length===0)return a(o,{dimColor:!0,children:"no live processes"});let n=Date.now();return a(i,{flexDirection:"column",children:e.slice(0,12).map((s,u)=>{let p=I(t,u===r),y=Math.max(0,Math.round((n-(s.lastTurnAt||s.spawnedAt))/1e3)),f=s.state==="dead"?"red":s.state==="warm-hot"?"green":"yellow";return c(i,{children:[a(o,{...p,color:f,children:T(s.state,10)}),a(o,{...p,children:T(s.key.agentId,12)}),a(o,{...p,children:T(s.key.channel,10)}),c(o,{...p,children:[s.turnCount,"t ",y,"s"]})]},`${s.key.agentId}-${s.key.channel}-${s.key.chatId}-${u}`)})})}function te({rows:e}){return e.length===0?a(o,{dimColor:!0,children:"no crons"}):a(i,{flexDirection:"column",children:e.slice(0,12).map(r=>{let t=r.enabled?r.consecutiveErrors>0?a(o,{color:"red",children:"err"}):a(o,{color:"green",children:"ok"}):a(o,{dimColor:!0,children:"off"}),n=r.nextRun?new Date(r.nextRun).toLocaleTimeString():"\u2014";return c(i,{children:[a(o,{children:T(r.id,16)}),a(o,{dimColor:!0,children:T(r.schedule,12)}),a(o,{children:T(n,10)}),a(i,{children:t})]},r.id)})})}function re({rows:e}){if(e.length===0)return a(o,{dimColor:!0,children:"(waiting for channel events\u2026)"});let r=[...e].sort((t,n)=>n.lastAt-t.lastAt);return a(i,{flexDirection:"column",children:r.slice(0,12).map(t=>c(i,{children:[a(o,{children:T(t.channel,12)}),c(o,{color:"cyan",children:["\u2190",T(String(t.inbound),4)]}),c(o,{color:"magenta",children:["\u2192",T(String(t.outbound),4)]}),a(o,{dimColor:!0,children:t.lastPreview})]},t.channel))})}function ne({rows:e,cursor:r,focused:t}){return e.length===0?a(o,{dimColor:!0,children:"(waiting for events\u2026)"}):a(i,{flexDirection:"column",children:e.slice(0,18).map((n,s)=>{let u=I(t,s===r);return c(i,{children:[a(o,{...u,dimColor:!0,children:new Date(n.at).toLocaleTimeString().padEnd(10)}),a(o,{...u,color:ce(n.kind),children:T(n.kind,8)}),a(o,{...u,children:n.line})]},`${n.at}-${s}`)})})}function oe({chat:e,suggest:r,agents:t}){let n=e.history.slice(-14),s=t.find(f=>f.id===e.agentId),u=H(s?.tier??"",s?.model),p=e.status==="sending"?[...e.history].reverse().find(f=>f.role==="agent"&&f.streaming):void 0,y=e.status==="sending"?a(O,{startedAt:p?.at??Date.now(),phase:p?.text?"responding":"thinking",indent:""}):e.error?c(o,{color:"red",children:["\u25CF ",e.error]}):a(o,{dimColor:!0,children:"\u25CF ready"});return c(i,{flexDirection:"column",width:"50%",borderStyle:"double",borderColor:"green",paddingX:1,children:[c(i,{justifyContent:"space-between",children:[c(o,{bold:!0,color:"green",children:["CHAT \xB7 @",e.agentId]}),a(i,{children:y})]}),c(o,{children:[c(o,{color:u.color,bold:!0,children:[u.glyph," ",u.label]}),s?.model?c(o,{dimColor:!0,children:[" ",j(s.model)]}):null,c(o,{dimColor:!0,children:[" \xB7 ",e.chatId]})]}),a(i,{flexDirection:"column",flexGrow:1,marginTop:1,children:n.length===0?a(o,{dimColor:!0,children:"(type a message and press Enter \u2014 Esc exits, Ctrl-L starts fresh)"}):n.map((f,l)=>a(se,{turn:f,agentId:e.agentId},`${f.at}-${l}`))}),r?c(o,{dimColor:!0,children:[a(o,{color:"cyan",children:"\u21B9"})," ",r.items.slice(0,5).map((f,l)=>l===0?a(o,{color:"cyan",children:f},l):c(o,{children:[" ",f]},l))]}):null,c(i,{children:[a(o,{color:"cyan",children:"you \u203A "}),a(o,{children:e.text}),a(o,{inverse:!0,children:" "})]})]})}function se({turn:e,agentId:r}){if(e.role==="you")return c(i,{flexDirection:"column",marginBottom:1,children:[a(o,{color:"cyan",children:"you"}),e.text.split(`
|
|
5
5
|
`).map((s,u)=>c(o,{children:[" ",s]},u))]});if(e.role==="error")return c(i,{flexDirection:"column",marginBottom:1,children:[a(o,{color:"red",children:"error"}),c(o,{color:"red",children:[" ",e.text]})]});let t=e.elapsedMs!=null?` \xB7 ${(e.elapsedMs/1e3).toFixed(1)}s${e.outTokens!=null?`, ${e.outTokens} tok`:""}`:e.streaming?" \xB7 \u2026":"",n=F(e.text,58,{balance:e.streaming});return c(i,{flexDirection:"column",marginBottom:1,children:[c(o,{color:"green",children:["@",r??"agent",a(o,{dimColor:!0,children:t})]}),e.thinking?e.thinking.split(`
|
|
6
6
|
`).filter(s=>s.trim()).slice(-2).map((s,u)=>c(o,{dimColor:!0,italic:!0,children:[" ",s]},`th${u}`)):null,(e.tools??[]).map((s,u)=>c(o,{color:s.error?"red":"green",children:[" \u25CF ",c(o,{bold:!s.error,dimColor:s.error,children:[s.name,s.arg?c(o,{dimColor:!0,children:["(",s.arg,")"]}):null,s.error?" failed":""]})]},`tool${u}`)),n.split(`
|
|
7
7
|
`).slice(0,14).map((s,u)=>c(o,{children:[" ",s]},u))]})}function ae(e){let r=e.data??{},t=typeof r.at=="string"||typeof r.at=="number"?new Date(r.at).getTime():Date.now(),n="";switch(e.event){case"run":n=`${r.phase??""} ${r.workflowId??""} ${(r.runId??"").slice(0,8)} ${r.nodeId??""}`.trim();break;case"task":n=`${r.phase??""} ${r.workflowId??""} ${Array.isArray(r.assignedTo)?r.assignedTo.join(","):""} ${r.title?`"${r.title}"`:""}`.trim();break;case"signal":n=`${r.name??""} (${r.scope??""}) ${r.workflowId??""}`.trim();break;case"mesh":n=`${r.peer??""} ${r.healthy?"healthy":"lost"} ${r.delta??""}`.trim();break;case"channel":{n=`${r.direction==="in"?"\u2190":"\u2192"} ${r.channel??""}:${r.chatId??""} ${r.textPreview??""}`.trim();break}case"status":n=`node=${r.node??""} agents=${r.agents??0} active=${(r.active??[]).length}`;break;default:n=typeof r=="string"?r:JSON.stringify(r).slice(0,80)}return{at:Number.isFinite(t)?t:Date.now(),kind:e.event,line:n}}function ce(e){switch(e){case"run":return"cyan";case"task":return"magenta";case"signal":return"green";case"mesh":return"blue";case"channel":return"yellow";default:return"white"}}function T(e,r){let t=(e??"").toString();return t.length>=r?t.slice(0,r-1)+" ":t+" ".repeat(r-t.length)}export{be as App};
|
|
8
|
-
//# sourceMappingURL=App-
|
|
8
|
+
//# sourceMappingURL=App-EYUDDF6K.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as Y,b as Z,c as _,d as ee,e as te,f as ne,g as re}from"./chunk-U2CKL755.js";import{b as Q,g as X}from"./chunk-
|
|
1
|
+
import{a as Y,b as Z,c as _,d as ee,e as te,f as ne,g as re}from"./chunk-U2CKL755.js";import{b as Q,g as X}from"./chunk-PYCTWI2I.js";import"./chunk-ECM2QEXF.js";import"./chunk-RJ7DASOU.js";import"./chunk-BRK6M6LA.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";import{useCallback as oe,useMemo as H,useRef as P,useState as k}from"react";import{Box as g,Text as t,useApp as he,useInput as xe,useStdout as Te}from"ink";import{randomUUID as se}from"crypto";var m={accent:"cyan",agent:"green",working:"magenta",error:"red",muted:"gray"},q="\u25C7 agentx",F="\u258C";import{jsx as c,jsxs as o}from"react/jsx-runtime";var ie="/help /agent <id> /agents /clear /who /exit",be=[{cmd:"/agent",desc:"switch the target agent (/agent <id>)"},{cmd:"/agents",desc:"list registered agents"},{cmd:"/clear",desc:"start a fresh session"},{cmd:"/who",desc:"show agent + chat id"},{cmd:"/help",desc:"list commands"},{cmd:"/exit",desc:"quit the chat"}];function Pe({conn:n,agentId:p,channel:f,chatId:a,agents:h}){let{exit:w}=he(),{stdout:O}=Te(),V=Math.max(40,Math.min((O?.columns||80)-4,100)),[z,U]=k([]),[$,S]=k(null),[T,le]=k(p),[A,ae]=k(h),[E,ue]=k(a),[y,x]=k(""),[J,de]=k(""),W=P([]),u=P(-1),M=P(null),R=P(null),v=$?.live??!1,j=H(()=>Z(y,A.map(s=>s.id),process.cwd()),[y,A]),N=H(()=>{let s=/^\/(\w*)$/.exec(y);if(!s)return null;let e=be.filter(r=>r.cmd.slice(1).startsWith(s[1].toLowerCase()));return e.length?e:null},[y]),b=s=>de(s),K=oe(s=>{let e=se().slice(0,8),r=Date.now(),i=new AbortController;R.current=i;let d={id:e,you:s,agentId:T,segs:[],live:!0,startedAt:r};S({...d});let L=()=>S({...d,segs:d.segs.map(C=>({...C}))});(async()=>{try{let C=await X(n,T,s,{channel:f,chatId:E,signal:i.signal,onText:l=>{let I=d.segs[d.segs.length-1];I&&I.type==="text"?I.content=(I.content??"")+l:d.segs.push({type:"text",content:l}),L()},onThinking:l=>{d.thinking=(d.thinking??"")+l,L()},onTool:l=>{l.status==="start"&&l.name?(d.segs.push({type:"tool",name:l.name,arg:l.arg}),L()):l.status==="result"&&l.error&&(d.segs.push({type:"tool",name:l.name??"tool",error:!0}),L())}});U(l=>[...l,{...d,live:!1,elapsedMs:Date.now()-r,outTokens:C.usage?.outputTokens,error:C.error}]),S(null)}catch(C){let l=i.signal.aborted||C?.name==="AbortError";U(I=>[...I,{...d,live:!1,elapsedMs:Date.now()-r,interrupted:l,error:l?void 0:C?.message||String(C)}]),S(null)}finally{R.current===i&&(R.current=null)}})()},[n,T,f,E]),me=oe(s=>{let e=s.trim();if(e){if(W.current.push(e),u.current=-1,e==="/exit"||e==="/quit"){w();return}if(e==="/help"){b(ie);return}if(e==="/who"){b(`@${T} \xB7 chatId=${E} \xB7 channel=${f}`);return}if(e==="/clear"){let r=`chat-cli:${se().slice(0,12)}`;ue(r),U([]),b(`fresh chatId=${r} (warm process dropped)`);return}if(e==="/agents"){Q(n).then(r=>{ae(r),b(r.map(i=>i.id===T?`[${i.id}]`:i.id).join(" "))}).catch(r=>b(`failed to list agents: ${r?.message||r}`));return}if(e.startsWith("/agent ")){let r=e.slice(7).replace(/^@/,"").trim();if(!r){b("usage: /agent <id>");return}if(!A.find(i=>i.id===r)){b(`unknown agent: @${r}`);return}le(r),b(`now talking to @${r}`);return}if(e.startsWith("/")){b(`unknown command \xB7 ${ie}`);return}K(e)}},[n,T,A,f,E,w,K]);xe((s,e)=>{if(e.ctrl&&s==="c"){w();return}if(e.escape){if(v&&R.current){R.current.abort();return}w();return}if(e.tab){if(N){x(N[0].cmd+" ");return}let i=_(y,M,A.map(d=>d.id),process.cwd());i!==null&&(x(i),u.current=-1);return}if(e.upArrow){let i=W.current;if(!i.length)return;u.current=u.current<0?i.length-1:Math.max(0,u.current-1),x(i[u.current]??"");return}if(e.downArrow){let i=W.current;if(u.current<0)return;if(u.current=u.current+1,u.current>=i.length){u.current=-1,x("");return}x(i[u.current]??"");return}if(e.backspace||e.delete){M.current=null,x(i=>i.slice(0,-1));return}if(e.ctrl||e.meta)return;let r=ee(s??"",e.return,y);switch(r.kind){case"paste":M.current=null,x(i=>i+r.text),u.current=-1;return;case"type":M.current=null,x(i=>i+r.text),u.current=-1;return;case"continue":x(r.buffer);return;case"submit":if(v)return;M.current=null,x(""),me(r.text);return;case"none":return}});let G=v?m.working:m.accent,ge=y.length?y.split(`
|
|
2
2
|
`):[""],B=A.find(s=>s.id===T),D=ne(B?.tier??"",B?.model),pe=O?.rows||24,fe=z.slice(-40);return o(g,{flexDirection:"column",height:pe,children:[o(g,{flexDirection:"column",flexGrow:1,justifyContent:"flex-end",overflow:"hidden",children:[z.length===0&&!$?o(g,{flexDirection:"column",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),c(t,{dimColor:!0,children:" \u2014 chat with "}),o(t,{color:m.accent,children:["@",T]}),c(t,{dimColor:!0,children:" via "}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" (",B.model,")"]}):null]}),c(t,{dimColor:!0,children:"streaming \xB7 markdown \xB7 tools \xB7 type a message, or / for commands"})]}):null,fe.map(s=>c(ce,{turn:s,width:V},s.id)),$?c(ce,{turn:$,width:V}):null]}),N?c(g,{flexDirection:"column",marginTop:1,children:N.map((s,e)=>o(g,{children:[c(t,{color:e===0?m.accent:m.muted,bold:e===0,children:s.cmd.padEnd(10)}),c(t,{dimColor:!0,children:s.desc})]},s.cmd))}):j?o(g,{marginTop:1,children:[c(t,{color:m.accent,children:"\u21B9 "}),j.items.map((s,e)=>o(t,{color:e===0?m.accent:m.muted,children:[s,e<j.items.length-1?" ":""]},e))]}):J?c(g,{marginTop:1,children:c(t,{dimColor:!0,children:J})}):null,c(g,{borderStyle:"single",borderColor:G,borderLeft:!1,borderRight:!1,borderDimColor:!v,width:"100%",children:c(g,{flexDirection:"column",width:"100%",children:ge.map((s,e,r)=>o(g,{children:[c(t,{color:G,bold:!0,children:e===0?"\u203A ":" "}),c(t,{children:s}),e===r.length-1&&!v?c(t,{color:G,children:"\u258F"}):null]},e))})}),o(g,{justifyContent:"space-between",children:[o(t,{children:[c(t,{color:m.accent,bold:!0,children:q}),o(t,{dimColor:!0,children:[" \xB7 @",T," \xB7 "]}),o(t,{color:D.color,bold:!0,children:[D.glyph," ",D.label]}),B?.model?o(t,{dimColor:!0,children:[" ",re(B.model)]}):null]}),o(t,{dimColor:!0,children:["\u21B5 send / cmds @ mention esc ",v?"stop":"exit"]})]})]})}function ce({turn:n,width:p}){let f=H(()=>ye(n,p),[n,p]),a=n.segs.some(h=>h.type==="text"&&h.content);return o(g,{flexDirection:"column",marginBottom:1,children:[o(t,{color:m.accent,bold:!0,children:[F," you"]}),n.you.split(`
|
|
3
3
|
`).map((h,w)=>o(t,{color:"white",children:[" ",h]},`u${w}`)),o(t,{color:m.agent,bold:!0,children:[F," ",n.agentId??"agent"]}),n.thinking?c(g,{flexDirection:"column",children:we(n.thinking,n.live?3:2).map((h,w)=>o(t,{dimColor:!0,italic:!0,children:[" ",h]},`th${w}`))}):null,f,n.live?c(te,{startedAt:n.startedAt,phase:a?"responding":"thinking",hint:"esc to interrupt"}):n.interrupted?o(t,{dimColor:!0,children:[" \u2298 interrupted \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s"]}):n.error?o(t,{color:"red",children:[" \u2717 ",n.error]}):n.elapsedMs!=null?o(t,{dimColor:!0,children:[" \xB7 ",(n.elapsedMs/1e3).toFixed(1),"s",n.outTokens!=null?`, ${n.outTokens} tok`:""]}):null]})}function we(n,p){return n.split(`
|
|
4
4
|
`).filter(a=>a.trim()).slice(-p)}function ye(n,p){let f=[];return n.segs.forEach((a,h)=>{a.type==="tool"?f.push(o(t,{color:a.error?"red":"green",children:[" ","\u25CF ",o(t,{bold:!a.error,dimColor:a.error,children:[a.name,a.arg?o(t,{dimColor:!0,children:["(",a.arg,")"]}):null,a.error?" failed":""]})]},h)):a.content&&f.push(c(t,{children:Ce(Y(a.content,p,{balance:n.live}))},h))}),f}function Ce(n){return n.split(`
|
|
5
5
|
`).map(p=>p.length?" "+p:p).join(`
|
|
6
6
|
`)}export{Pe as ChatApp};
|
|
7
|
-
//# sourceMappingURL=ChatApp-
|
|
7
|
+
//# sourceMappingURL=ChatApp-F5LZLBI3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as a,B as b,C as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=agent-
|
|
1
|
+
import{A as a,B as b,C as c}from"./chunk-HMDM5MCR.js";import"./chunk-SFQUP3BP.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-QIJLFPWE.js";export{a as createAgentContext,b as generate,c as generateStream};
|
|
2
|
+
//# sourceMappingURL=agent-XF3BWMOB.js.map
|