Skip to main content

EdgeHalo API reference

EdgeHalo manages the local personalization lifecycle: profile jobs, Neural Imprint capsule compatibility, and restore orchestration.

Developer Preview

Some profile-analysis and capsule APIs are intentionally low-level in the current preview. Prefer the Edge Scaffold reference flow when starting a new integration.

EdgeHalo

public actor EdgeHalo

Main entry point.

Property or methodDescription
init(engine:generator:dataStream:)Creates an EdgeHalo actor with app-provided runtime bridges.
evolutionStateHigh-level model evolution state for product UI.
currentProfileMost recent local profile result, if available.
haloStateCapsule validation and restore state.
activeCapsuleActive HaloCapsule, if a compatible Neural Imprint is restored.
runProfileAnalysis(...)Runs a local profile job from prepared inputs and exported resources.
validateCapsule(_:currentRequirements:)Checks whether a capsule can be restored into the current runtime.
activateCapsule(_:currentRequirements:)Restores a compatible capsule. Fails closed on mismatch.

HaloTextGenerator

public protocol HaloTextGenerator: Sendable

Text-generation provider implemented by the agent.

MethodDescription
tokenize(_:)Converts text into token IDs with the tokenizer that matches the loaded model.
generate(prompt:maxTokens:)Runs short local generations used by the profile workflow.

HaloEngineSession

public protocol HaloEngineSession: Sendable

Runtime bridge implemented by the agent. Edge Halo does not import Edge Kit directly; the app wires both packages together.

MethodDescription
captureHiddenState(tokens:layer:)Captures model state needed by the profile workflow.
captureFullCache(tokenIds:)Captures a local Neural Imprint prefix artifact when supported.
restoreFullCache(_:artifactURL:)Restores a compatible Neural Imprint artifact.

The current preview protocol also contains advanced optional runtime hooks. Most agents can leave those unsupported unless a release note or scaffold integration requires them.

EvolutionState

public enum EvolutionState: Sendable, Equatable
CaseDescription
.idleNo active evolution task.
.collecting(progress:)Collecting eligible local data toward a profile refresh.
.readyToBuildCapsuleEnough data is available to build or receive a new artifact.
.buildingCapsuleA local artifact is being prepared.
.validating(capsuleID:)A capsule is being checked before restore.
.evolved(capsuleID:)A compatible capsule is active.

HaloState

public enum HaloState: Sendable, Equatable

Capsule-level state for settings UI and diagnostics.

CaseDescription
.idleNo capsule state.
.collecting(factsCount:threshold:)More local data is needed before personalization can run.
.profilingProfile inputs are being prepared.
.buildingCapsuleA Neural Imprint artifact is being prepared.
.validating(capsuleID:)Compatibility gates are running.
.active(capsuleID:)A compatible capsule is restored.
.incompatible(capsuleID:reason:)Restore was rejected. Keep the base model active.
.failed(reason:)Lifecycle failed. Show a recovery action.

HaloCapsule

public struct HaloCapsule: Sendable, Equatable, Codable

Container for a Neural Imprint capsule manifest and optional local artifact URL.

PropertyType
manifestHaloCapsuleManifest
artifactURLURL?

HaloCapsuleManifest

public struct HaloCapsuleManifest: Sendable, Equatable, Codable

Metadata used to validate and describe a capsule.

PropertyDescription
capsuleIDStable identifier for the capsule.
createdAtCreation time.
baseModelIDBase model this capsule targets.
requirementsRuntime identity required for restore.
cacheSnapshotSnapshot metadata for the artifact.
artifactSHA256Hash of the local artifact bytes, when available.

HaloCapsuleRequirements

public struct HaloCapsuleRequirements: Sendable, Equatable, Codable

Runtime identity used for fail-closed restore checks.

PropertyDescription
modelFamily, hiddenSize, layerCountModel-shape identity.
modelConfigSHA256, modelWeightsFingerprintModel config and weights identity.
tokenizerJSONSHA256, tokenizerConfigSHA256Tokenizer identity.
chatTemplateSHA256Chat-template identity.
toolSchemaSHA256Tool schema identity.
profileBodySHA256Profile source identity without exposing profile text.
cacheBackend, cacheBackendVersion, cacheTopologySHA256Runtime cache identity.

Use:

let result = capsule.manifest.requirements.compatibility(with: current)
if result.isCompatible {
try await halo.activateCapsule(capsule, currentRequirements: current)
}

UserProfile

public struct UserProfile: Sendable

Local profile narrative produced by the preview profile workflow.

PropertyType
directionNames[String]
narrativeString
sampleCountInt
computedAtDate
stabilityScoreFloat

The numeric fields are runtime data. Product UI should usually show the narrative, freshness, sample count, and reset controls rather than raw vectors.

HaloDataEvent

public enum HaloDataEvent: Sendable

Optional event stream for lifecycle decisions.

CaseDescription
.feedback(accepted:conversationID:)User feedback for a response.
.correction(original:corrected:conversationID:)User correction for a response.
.sessionCompleted(turnCount:conversationID:)Completed conversation session.