agentix-cli 0.226.2 → 0.226.3
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/AgentClient.swift +8 -4
- package/apps/mac-voice/Sources/AgentXVoice/OpenRequests.swift +32 -5
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +6 -0
- package/dist/{agent-QCB3FOPN.js → agent-F2VJKD7X.js} +2 -2
- package/dist/{chunk-TEYFN6YL.js → chunk-4H5B42VW.js} +99 -99
- package/dist/{chunk-TEYFN6YL.js.map → chunk-4H5B42VW.js.map} +1 -1
- package/dist/{chunk-W7PIHJHH.js → chunk-LACHXOBO.js} +2 -2
- package/dist/{chunk-X2LFAJ5D.js → chunk-NVHEWULT.js} +266 -266
- package/dist/chunk-NVHEWULT.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{program-YIKCSZBC.js → program-FZBZUK5X.js} +4 -4
- package/dist/{registry-77HLNAQF.js → registry-PA45HSJ4.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-X2LFAJ5D.js.map +0 -1
- /package/dist/{agent-QCB3FOPN.js.map → agent-F2VJKD7X.js.map} +0 -0
- /package/dist/{chunk-W7PIHJHH.js.map → chunk-LACHXOBO.js.map} +0 -0
- /package/dist/{program-YIKCSZBC.js.map → program-FZBZUK5X.js.map} +0 -0
- /package/dist/{registry-77HLNAQF.js.map → registry-PA45HSJ4.js.map} +0 -0
|
@@ -275,9 +275,12 @@ enum AgentClient {
|
|
|
275
275
|
static func ask(_ message: String, agent: String, handsFree: Bool = false, request: String? = nil) async throws -> Answer {
|
|
276
276
|
var req = URLRequest(url: URL(string: "\(Config.daemonURL)/ask")!)
|
|
277
277
|
req.httpMethod = "POST"
|
|
278
|
-
// An agent turn routinely takes minutes
|
|
279
|
-
//
|
|
280
|
-
|
|
278
|
+
// An agent turn routinely takes minutes, and before it starts it
|
|
279
|
+
// may wait up to an hour for room on the computer (the daemon's
|
|
280
|
+
// admission queue). The daemon always ends the wait itself: with
|
|
281
|
+
// the answer, or with why there is none. Giving up here first
|
|
282
|
+
// showed "The request timed out" for a turn that was still coming.
|
|
283
|
+
req.timeoutInterval = OpenRequests.askTimeout
|
|
281
284
|
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
282
285
|
var payload: [String: Any] = ["message": message, "session": Config.voiceSession]
|
|
283
286
|
// No agent known: the daemon answers with its default agent.
|
|
@@ -367,12 +370,13 @@ enum AgentClient {
|
|
|
367
370
|
let since: Double
|
|
368
371
|
let heard: Bool
|
|
369
372
|
let error: String?
|
|
373
|
+
let held: String?
|
|
370
374
|
|
|
371
375
|
var remote: OpenRequests.Remote {
|
|
372
376
|
OpenRequests.Remote(key: id, agentID: agentId, question: question,
|
|
373
377
|
sentAt: Date(timeIntervalSince1970: sentAt / 1000),
|
|
374
378
|
since: Date(timeIntervalSince1970: since / 1000),
|
|
375
|
-
state: state, heard: heard, error: error)
|
|
379
|
+
state: state, heard: heard, error: error, held: held)
|
|
376
380
|
}
|
|
377
381
|
}
|
|
378
382
|
|
|
@@ -50,6 +50,12 @@ struct OpenRequests {
|
|
|
50
50
|
/// A follow-up spoken while it was thinking: asked as soon as the
|
|
51
51
|
/// answer is back.
|
|
52
52
|
var pending: String? = nil
|
|
53
|
+
/// From the daemon while it thinks: why its turn has not started
|
|
54
|
+
/// yet (the computer has no room). Nil once the turn runs.
|
|
55
|
+
var held: String? = nil
|
|
56
|
+
|
|
57
|
+
/// Thinking, but its turn has not started: it waits for room.
|
|
58
|
+
var isHeld: Bool { phase == .thinking && held != nil }
|
|
53
59
|
|
|
54
60
|
/// An answer or a failure the owner has not seen yet.
|
|
55
61
|
var isNew: Bool {
|
|
@@ -121,6 +127,7 @@ struct OpenRequests {
|
|
|
121
127
|
requests[i].since = now
|
|
122
128
|
requests[i].heard = false
|
|
123
129
|
requests[i].local = true
|
|
130
|
+
requests[i].held = nil
|
|
124
131
|
return busy ? .waits : .ask
|
|
125
132
|
}
|
|
126
133
|
}
|
|
@@ -133,17 +140,18 @@ struct OpenRequests {
|
|
|
133
140
|
requests[i].pending = nil
|
|
134
141
|
requests[i].phase = .thinking
|
|
135
142
|
requests[i].since = now
|
|
143
|
+
requests[i].held = nil
|
|
136
144
|
return true
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
/// The answer came back.
|
|
140
148
|
mutating func answered(_ id: Int, at now: Date) {
|
|
141
|
-
update(id) { $0.phase = .answered; $0.since = now }
|
|
149
|
+
update(id) { $0.phase = .answered; $0.since = now; $0.held = nil }
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
/// The agent could not answer.
|
|
145
153
|
mutating func failed(_ id: Int, reason: String, at now: Date) {
|
|
146
|
-
update(id) { $0.phase = .failed(reason); $0.since = now }
|
|
154
|
+
update(id) { $0.phase = .failed(reason); $0.since = now; $0.held = nil }
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
/// The oldest request waiting for `agentID`, now thinking, if there is
|
|
@@ -235,6 +243,8 @@ struct OpenRequests {
|
|
|
235
243
|
let state: String
|
|
236
244
|
let heard: Bool
|
|
237
245
|
let error: String?
|
|
246
|
+
/// Why its turn has not started yet, while it thinks.
|
|
247
|
+
var held: String? = nil
|
|
238
248
|
|
|
239
249
|
var phase: Phase {
|
|
240
250
|
switch state {
|
|
@@ -260,6 +270,9 @@ struct OpenRequests {
|
|
|
260
270
|
for i in requests.indices {
|
|
261
271
|
guard let key = requests[i].key, let theirs = byKey[key] else { continue }
|
|
262
272
|
if theirs.heard { requests[i].heard = true }
|
|
273
|
+
// Held or not is the daemon's to say, for a row this app runs
|
|
274
|
+
// too: its /ask is still open while the turn waits for room.
|
|
275
|
+
if requests[i].phase == .thinking, theirs.state == "thinking" { requests[i].held = theirs.held }
|
|
263
276
|
guard !requests[i].local else { continue }
|
|
264
277
|
if requests[i].phase != theirs.phase {
|
|
265
278
|
requests[i].phase = theirs.phase
|
|
@@ -275,7 +288,7 @@ struct OpenRequests {
|
|
|
275
288
|
nextID += 1
|
|
276
289
|
restore(Request(id: id, agentID: theirs.agentID, question: theirs.question, sentAt: theirs.sentAt,
|
|
277
290
|
phase: theirs.phase, since: theirs.since, heard: theirs.heard,
|
|
278
|
-
key: theirs.key, local: false))
|
|
291
|
+
key: theirs.key, local: false, held: theirs.state == "thinking" ? theirs.held : nil))
|
|
279
292
|
joined.append(id)
|
|
280
293
|
}
|
|
281
294
|
return joined
|
|
@@ -408,7 +421,7 @@ struct OpenRequests {
|
|
|
408
421
|
static func stateWords(_ r: Request, now: Date) -> String {
|
|
409
422
|
switch r.phase {
|
|
410
423
|
case .waiting: return "Waiting its turn"
|
|
411
|
-
case .thinking: return "Thinking, " + clock(Int(now.timeIntervalSince(r.since)))
|
|
424
|
+
case .thinking: return (r.isHeld ? "Waiting for room, " : "Thinking, ") + clock(Int(now.timeIntervalSince(r.since)))
|
|
412
425
|
case .answered: return r.heard ? "Heard" : "Answer ready"
|
|
413
426
|
case .failed: return "Couldn’t answer"
|
|
414
427
|
}
|
|
@@ -422,7 +435,8 @@ struct OpenRequests {
|
|
|
422
435
|
case .waiting: state = "Waiting its turn"
|
|
423
436
|
case .thinking:
|
|
424
437
|
let s = Int(now.timeIntervalSince(r.since))
|
|
425
|
-
|
|
438
|
+
let word = r.isHeld ? "Waiting for room on this computer" : "Thinking"
|
|
439
|
+
state = s < 60 ? word : "\(word), \(s / 60) minute\(s / 60 == 1 ? "" : "s")"
|
|
426
440
|
case .answered: state = r.heard ? "Heard" : "Answer ready, not heard"
|
|
427
441
|
case .failed: state = r.heard ? "Couldn’t answer" : "Couldn’t answer, not seen"
|
|
428
442
|
}
|
|
@@ -447,6 +461,19 @@ struct OpenRequests {
|
|
|
447
461
|
/// The pill's line when an answer comes back and waits.
|
|
448
462
|
static func readyNote(name: String) -> String { "\(name) answered · hover or ⌘⌥O to hear it" }
|
|
449
463
|
|
|
464
|
+
/// The longest an /ask is waited for: the daemon's longest queue wait
|
|
465
|
+
/// (60 minutes by default) plus a long turn.
|
|
466
|
+
static let askTimeout: TimeInterval = 4 * 3600
|
|
467
|
+
|
|
468
|
+
/// The pill's line when a request's turn cannot start yet: the
|
|
469
|
+
/// computer has no room. It is not a failure; the answer still comes.
|
|
470
|
+
static func heldNote(name: String) -> String { "\(name) is waiting for room on this Mac · the answer will come" }
|
|
471
|
+
|
|
472
|
+
/// Rows held in `now` that were not held in `before`.
|
|
473
|
+
static func newlyHeld(before: [Request], now: [Request]) -> [Request] {
|
|
474
|
+
now.filter { r in r.isHeld && !(before.first { $0.id == r.id }?.isHeld ?? false) }
|
|
475
|
+
}
|
|
476
|
+
|
|
450
477
|
/// The pill's line when a request fails.
|
|
451
478
|
static func failedNote(name: String) -> String { "\(name) couldn’t answer · ⌘⌥O to see why" }
|
|
452
479
|
|
|
@@ -1449,6 +1449,12 @@ final class App: NSObject, NSApplicationDelegate {
|
|
|
1449
1449
|
for agent in Set(requests.requests.filter { $0.phase == .waiting }.map(\.agentID)) {
|
|
1450
1450
|
if let next = requests.startNext(for: agent, at: now) { run(next) }
|
|
1451
1451
|
}
|
|
1452
|
+
// A turn that cannot start yet: said once on the pill, so a long
|
|
1453
|
+
// wait is not mistaken for a lost request.
|
|
1454
|
+
for r in OpenRequests.newlyHeld(before: before, now: requests.requests) {
|
|
1455
|
+
Log.info("request \(r.id) waits for room (\(r.agentID)): \(r.held ?? "")")
|
|
1456
|
+
note(OpenRequests.heldNote(name: statusMenu.name(of: r.agentID)))
|
|
1457
|
+
}
|
|
1452
1458
|
if requests.requests != before { requestsChanged() }
|
|
1453
1459
|
}
|
|
1454
1460
|
|
|
@@ -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-LACHXOBO.js";import"./chunk-SFQUP3BP.js";import"./chunk-LY4G7PCW.js";import"./chunk-AHWWJ7AF.js";import"./chunk-DCIYOPJF.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-F2VJKD7X.js.map
|