Skip to main content

Local Edge AI (QVAC)

Totem is being extended so devices run their own AI inference — models on the edge, not cloud APIs. Two new packages make this safe to wire into the mining, payment, and policy core:

PackageRole
@totemsdk/intelligenceProvider-neutral contracts — capabilities, operations, usage receipts, error codes, and the EdgeIntelligencePort
@totemsdk/qvacQVAC adapter — wraps @qvac/sdk into those contracts, with runtime capability discovery and per-domain adapters

Trust model: the AI proposes, Totem authorizes

An IntelligenceProvider is a compute surface, never a signing surface.

  • Inference runs locally/self-hosted inside the device's own process.
  • The inference layer cannot sign transactions and never holds keys.
  • Every inference is keyed by a proposalId / runId so policy layers upstream (@totemsdk/agent-policy, @totemsdk/authority) can authorize, meter, and budget it the same way they authorize a payment.

What the contracts provide

  • Domainsllm, embed, rag, asr, translate, tts, diffusion, ocr, classify, audiogen, video, vla, world, models, system, plugins. Each surfaces as an intelligence:<domain> capability string, compatible with @totemsdk/edge's domain:action convention.
  • Operations — a stable domain + op + params shape so consumers never depend on a concrete provider's vocabulary.
  • Usage receiptsusage output per invocation (tokens, duration) is the metering unit that @totemsdk/agent-policy inference-cost flows consume.
  • ErrorsIntelligenceError carries a stable error code and a retryable flag for retries and budgets.

QVAC adapter

@totemsdk/qvac consumes @qvac/sdk at runtime only — injected, loaded via sdkLoader, or lazily required. The package has no manifest peer on the heavy native SDK: its type surface is vendored from the real @qvac/sdk@0.19.0 declarations, so adapter param/result types are genuine upstream signatures (e.g. CompletionParams requires modelId + history), and a CI drift audit (validate:qvac-drift) reinstalls the real SDK and verifies the wrapped op surface still exists upstream.

import * as qvac from '@qvac/sdk';
import { createQvacIntelligenceProvider } from '@totemsdk/qvac';

const provider = createQvacIntelligenceProvider({ sdk: qvac });

const result = await provider.invoke({
domain: 'llm',
op: 'completion',
params: { modelId: 'qvac-llm', history: [{ role: 'user', content: 'Summarize this invoice' }] },
});
if (result.ok) console.log(result.data, result.usage?.tokensOut);

Capability discovery. provider.capabilities reflects which domains are actually callable on the resolved SDK — a runtime without the RAG plugin stops advertising intelligence:rag.

Shapes & cancellation. The provider dispatches each op per the real SDK invocation shape (record / positional / callback), maps streamable run/session surfaces (textToSpeech audio samples, transcribeStream segments, completion token/progress/done, loggingStream deltas) onto IntelligenceStreamChunks, mirrors real adapter signatures, and forwards cancellation to sdk.cancel({ requestId }) when the SDK decorates pending promises with a requestId.

Edge integration

Routes intelligence:invoke / intelligence:cancel actions to the EdgeIntelligencePort:

import { createQvacEdgeIntelligencePort } from '@totemsdk/qvac/edge';
import { edgeRuntime } from '@totemsdk/edge';

const port = createQvacEdgeIntelligencePort({ sdk: qvac });
edgeRuntime.ports.intelligence = port;

Dispatch is capability-gated: intelligence:invoke fails with CAPABILITY_MISSING before touching the port if intelligence:<domain> is not in the runtime's EdgeCapabilitySet.

Learning more