new macOS version

This commit is contained in:
2026-04-01 16:10:30 -05:00
parent 56673078f5
commit 483e3c1d00
13 changed files with 2302 additions and 319 deletions

View File

@@ -265,6 +265,26 @@ final class APIClient {
// MARK: - Sessions
/// Returns all active + interrupted sessions (for VLM session context).
func getOpenSessions() async throws -> [OpenSession] {
do {
let data = try await req("/sessions/open")
return try decode([OpenSession].self, from: data)
} catch NetworkError.httpError(404, _) {
return []
}
}
/// Create a task detected by the VLM from screen analysis.
func createVLMTask(title: String) async throws -> AppTask {
let body = try JSONSerialization.data(withJSONObject: [
"title": title,
"source": "vlm_detected"
])
let data = try await req("/tasks", method: "POST", body: body)
return try decode(AppTask.self, from: data)
}
/// Returns the currently active session, or nil if none (404).
func getActiveSession() async throws -> FocusSession? {
do {
@@ -318,6 +338,28 @@ final class APIClient {
_ = try await req("/sessions/\(sessionId)/checkpoint", method: "POST", body: body)
}
// MARK: - Nudge (cross-device)
/// Send a focus-session nudge via the backend push pipeline to all signed-in devices.
func sendNudge(
sessionId: String,
title: String,
body: String,
nudgeNumber: Int,
lastStep: String?,
nextStep: String?
) async throws {
var dict: [String: Any] = [
"title": title,
"body": body,
"nudge_number": nudgeNumber,
]
if let ls = lastStep { dict["last_step"] = ls }
if let ns = nextStep { dict["next_step"] = ns }
let bodyData = try JSONSerialization.data(withJSONObject: dict)
_ = try await req("/sessions/\(sessionId)/nudge", method: "POST", body: bodyData)
}
// MARK: - App Activity
func appActivity(
@@ -352,14 +394,16 @@ final class APIClient {
if let stepId = result.currentStepId { payload["current_step_id"] = stepId }
if let note = result.checkpointNoteUpdate { payload["checkpoint_note_update"] = note }
if let app = result.appName { payload["app_name"] = app }
if let nudge = result.gentleNudge { payload["gentle_nudge"] = nudge }
if let notif = result.notification {
payload["notification"] = ["type": notif.type, "message": notif.message as Any]
}
if let friction = result.friction {
payload["friction"] = [
"type": friction.type,
"confidence": friction.confidence,
"description": friction.description as Any,
"proposed_actions": friction.proposedActions.map {
["label": $0.label, "action_type": $0.actionType, "details": $0.details as Any]
["label": $0.label, "details": $0.details as Any]
},
]
}