Files
zeekayandGitHub 5ecce95e3a feat: rename module path cloud→ai + cloud Mount() per HIP-0106 (#24)
* feat: rename module path cloud→ai + cloud Mount() per HIP-0106

The repo at hanzoai/ai was renamed from hanzoai/cloud on 2026-05-19.
This rotates the Go module path to match so the unified cloud binary
(hanzoai/cloud) can import this subsystem under its new name.

Module rename:
- go.mod: module github.com/hanzoai/cloud → module github.com/hanzoai/ai
- 236 .go files: import github.com/hanzoai/cloud/... → github.com/hanzoai/ai/...
- cloud.zap → schema/ai.zap (header + interface CloudService → interface AI)

HIP-0106 Mount:
- pkg/ai.Mount(*zip.App, cloud.Deps) error registers /v1/ai/* on the
  unified binary; the route layer strips the /v1/ai prefix and forwards
  to the beego ControllerRegister via zip.AdaptNetHTTP.
- A SetHandler injector lets main.go publish beego.BeeApp.Handlers
  after route init so the in-process embed and the standalone server
  share the same route table; X-Org-Id call-sites stay unchanged.
- schema/ai.zap describes the typed ZAP surface (chat, embeddings,
  knowledge / RAG, billing).

* refactor(consumer): import github.com/hanzoai/iam (drop iamsdk/v2)

Switch from github.com/hanzoai/iamsdk/v2/iamsdk to the canonical
github.com/hanzoai/iam root package. One canonical import path for
both the server and the SDK — same types, no drift.

  iamsdk "github.com/hanzoai/iamsdk/v2/iamsdk"   → iam "github.com/hanzoai/iam"
  iamsdk.Claims, iamsdk.User, …                  → iam.Claims, iam.User, …

23 files updated across controllers/, object/, routers/, storage/, util/.

go.mod: dropped iamsdk/v2 require, pinned iam to its current SHA
v1.16.2-0.20260519061152-86e34e93edf3 (drops cloud+zip transitive deps
via root SDK; submodule pkg/iam carries the cloud integration).

Pre-existing pkgmachine/gcp.go GCP API breakage (InstancesClient
relocated from computepb to apiv1 in compute v1.47+) is unaffected
by this change and not in scope.

* refactor: collapse pkg/ai/ → root + flatten cloud import

Repo IS the package. Mount() at root. Consumers use
`github.com/hanzoai/ai` (no /pkg/ai/ nesting).
2026-05-18 23:38:00 -07:00

223 lines
5.2 KiB
Plaintext

# Hanzo AI — ZAP Schema (HIP-0106)
#
# Server: hanzoai/ai mounted at /v1/ai inside the unified cloud binary.
# LLM control plane, RAG, model hub, MCP management.
#
# Code generation:
# zapc generate schema/ai.zap --lang go --out ./pkg/ai/zap/
# zapc generate schema/ai.zap --lang ts --out ./web/src/zap/
# zapc generate schema/ai.zap --lang py --out ./py/zap/
# zapc generate schema/ai.zap --lang rust --out ./rust/src/zap/
# ── Enums ────────────────────────────────────────────────────────────────
enum ModelProvider
openai
anthropic
google
together
groq
deepseek
fireworks
mistral
cohere
bedrock
zen
enum FinishReason
stop
length
content_filter
tool_calls
function_call
enum MessageRole
system
user
assistant
tool
function
enum StreamEvent
chunk
done
error
# ── Chat Completions ─────────────────────────────────────────────────────
struct ChatMessage
role Text
content Text
name Text
toolCalls List(ToolCall)
toolCallId Text
struct ToolCall
id Text
type Text
function FunctionCall
struct FunctionCall
name Text
arguments Text
struct ChatRequest
model Text
messages List(ChatMessage)
stream Bool
temperature Float32
maxTokens Int32
topP Float32
topK Int32
stop List(Text)
tools List(ToolDef)
toolChoice Text
user Text
seed Int64
n Int32
presencePen Float32
frequencyPen Float32
logprobs Bool
topLogprobs Int32
struct ToolDef
type Text
function FunctionDef
struct FunctionDef
name Text
description Text
parameters Text
struct ChatResponse
id Text
object Text
created Int64
model Text
choices List(Choice)
usage TokenUsage
systemFp Text
struct Choice
index Int32
message ChatMessage
finishReason Text
logprobs Text
struct StreamChunk
id Text
object Text
created Int64
model Text
choices List(StreamChoice)
usage TokenUsage
struct StreamChoice
index Int32
delta ChatMessage
finishReason Text
struct TokenUsage
promptTokens Int32
completionTokens Int32
totalTokens Int32
# ── Models ───────────────────────────────────────────────────────────────
struct ModelInfo
id Text
object Text
created Int64
ownedBy Text
premium Bool
contextLen Int32
maxOutput Int32
struct ModelList
object Text
data List(ModelInfo)
# ── Billing ──────────────────────────────────────────────────────────────
struct Balance
user Text
balance Float64
currency Text
available Float64
struct UsageRecord
id Text
user Text
model Text
provider Text
promptTok Int32
completTok Int32
totalTok Int32
cost Float64
timestamp Int64
# ── Embeddings ───────────────────────────────────────────────────────────
struct EmbeddingRequest
model Text
input List(Text)
user Text
struct EmbeddingData
index Int32
embedding List(Float32)
object Text
struct EmbeddingResponse
object Text
data List(EmbeddingData)
model Text
usage EmbeddingUsage
struct EmbeddingUsage
promptTokens Int32
totalTokens Int32
# ── Knowledge / RAG ─────────────────────────────────────────────────────
struct Store
name Text
displayName Text
provider Text
struct VectorSearchRequest
store Text
query Text
topK Int32
threshold Float32
struct VectorSearchResult
id Text
score Float32
content Text
metadata Text
# ── Service Interface ────────────────────────────────────────────────────
interface AI
# Chat completions (OpenAI-compatible)
chatCompletions (request ChatRequest) -> (response ChatResponse)
# Streaming chat completions (returns stream of StreamChunk)
chatCompletionsStream (request ChatRequest) -> (chunk StreamChunk)
# List available models
listModels () -> (list ModelList)
# Get user balance
getBalance (user Text, currency Text) -> (balance Balance)
# Create embeddings
createEmbeddings (request EmbeddingRequest) -> (response EmbeddingResponse)
# Vector search (RAG)
vectorSearch (request VectorSearchRequest) -> (results List(VectorSearchResult))
# Record usage (internal, from gateway)
recordUsage (record UsageRecord) -> ()