Skip to main content

Swift SDK

Swift integration for Zeq OS. Use HulyaSync for local temporal synchronization; call the REST API for operator computation.

Installation

// Package.swift
.package(path: "../sdk/swift")

Authentication

import Foundation

let BASE = "http://localhost"

func login(equation: String) async throws -> String {
let url = URL(string: "\(BASE)/api/users/login")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = try JSONSerialization.data(withJSONObject: ["equation": equation])
let (data, _) = try await URLSession.shared.data(for: req)
let json = try JSONSerialization.jsonObject(with: data) as! [String: Any]
return json["token"] as! String
}

let token = try await login(equation: "x^2 + sin(y*pi) + phi")

Quick Start

import Foundation

let BASE = "http://localhost"
let jwt = "your-jwt-token"

// 1. Browse operators — public, no auth
let opsData = try! Data(contentsOf: URL(string: "\(BASE)/api/zeq/operators")!)
let opsJSON = try! JSONSerialization.jsonObject(with: opsData) as! [String: Any]
let operators = opsJSON["operators"] as! [[String: Any]]
for op in operators.prefix(3) {
print("\(op["id"]!) \(op["name"]!) \(op["equation"]!)")
}

// 2. HulyaPulse phase — no auth
let phaseData = try! Data(contentsOf: URL(string: "\(BASE)/api/zeq/phase")!)
let phase = try! JSONSerialization.jsonObject(with: phaseData) as! [String: Any]
print("Phase: \(phase["phase"]!) KO42: \(phase["ko42"]!)")

// 3. Execute operator — requires account
func execute(operator op: String, params: [String: Any], token: String) async throws -> [String: Any] {
let url = URL(string: "\(BASE)/api/zeq/operators/execute?operator=\(op)")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
req.httpBody = try JSONSerialization.data(withJSONObject: ["params": params])
let (data, _) = try await URLSession.shared.data(for: req)
return try JSONSerialization.jsonObject(with: data) as! [String: Any]
}

let result = try await execute(operator: "NM21",
params: ["G": 6.674e-11, "m1": 5.97e24, "m2": 7.35e22, "r": 3.84e8],
token: jwt)
print("F = \(result["value"]!) N")

// 4. 7-Step Wizard — requires account
func wizard(query: String, operators: [String], token: String) async throws -> [String: Any] {
let url = URL(string: "\(BASE)/api/7step/run")!
var req = URLRequest(url: url)
req.httpMethod = "POST"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
req.httpBody = try JSONSerialization.data(withJSONObject: [
"query": query, "operators": operators, "mode": "basic"
])
let (data, _) = try await URLSession.shared.data(for: req)
return try JSONSerialization.jsonObject(with: data) as! [String: Any]
}

let state = try await wizard(query: "gravitational time dilation", operators: ["KO42", "GR37"], token: jwt)
print("Operators: \(state["selected_operators"]!)")
print("Master sum: \(state["master_sum"]!)")

HulyaSync (Local)

import ZeqOS

let sync = HulyaSync()

// All local — no server, no auth
print("Phase: \(sync.currentPhase())")
print("Zeqond: \(sync.getZeqond())")
print("KO42: \(sync.ko42Automatic())")

// Zeq Equation: R(t) = S(t) × [1 + α·sin(2πft)]
print("g mod: \(sync.modulate(9.80665))")
print(sync.daemonTick())

Framework Equations

Zeq Equation:   R(t) = S(t) × [1 + α × sin(2π × 1.287 × t)]
KO42: α × sin(2π × 1.287 × t)
HULYAS: □(φ) − μ²(r)φ − λφ³ − exp(−φ/φ_c) + φ₄₂ × Σ(Cₖ(φ)) = T^μ_μ + βF·F + J_ext

REST API Reference

EndpointAuthDescription
POST /api/users/loginLogin with equation
GET /api/zeq/phaseHulyaPulse phase + KO42
GET /api/zeq/operatorsAll operators + equations (public)
POST /api/zeq/operators/execute?operator=IDRequiredExecute operator
POST /api/7step/runRequired7-Step Wizard