feat: 唤醒式架构批次——capacity/L4/会话编排/管理面板写CRUD/前端集成(77-81)
【capacity 唤醒式核心(77)】internal/runtime/capacity:(Decider L1启发式+L2上下文+人格覆盖→三态静息/唤醒/全能→允许工具集+capacity_awaken事件)。loop 外围允许集过滤(不硬阻断=能力≠边界红线)。config 加 Capacity(Enabled/MinConfidence/ToolSets)。wire buildCapacity 接入 loop。 【L4 记忆驱动意图(80)】recall.go:从记忆召回用户习惯(搞一下xx=办事)→唤醒L1/L2漏掉/升置信;群聊陌生人不读owner习惯(隔离红线);RecordIntent闭环(判定写回记忆越用越准);默认保守静息。 【会话消息编排(78)】gateway/session_orchestrator.go:每会话(模式/pending有界5/tail上下文尾巴20);Submit非阻塞(idle立即/busy入队ack/满拒绝);完成回调按序续接(tail+新消息合并增量注入非全量重放);Interrupt中断;REST 202/409+WS session_busy/pending_ack事件;不重造任务引擎复用loop。 【前端集成(79)】ws.ts 加 capacity_awaken/session_busy/pending_ack 解析;store 加 awakenState/sessionBusy;TopBar/ChatShell 加唤醒态徽标+忙态提示(不阻塞输入框);状态组件 status.tsx;Miuix风格。 【管理面板写CRUD(81)】20个写端点(POST/PUT/DELETE /admin/*,owner+审计落库):personas(真持久化YAML)/users apikey(签发掩码+撤销)/iot控制(真下发)/automations(建/触发/删)/llm(test真调用+临时)/channels(connect/close/身份测试actor白名单)/plugins(卸载)/memories(search真检索)/sessions(export)。无存储如实501不伪造。拆4文件满足≤500红线。前端9模块接真写。 【wire收口】buildCapacity接入loop+OnCapacity事件;server.go newOrchestrator接hub。 实机验证:iot ac.living control 200 真实改变 on:true;observability/metrics 200、health ok;全仓 build/vet/test 47包绿+前端tsc/vite。
This commit is contained in:
1 parent
e0a543cc37
commit
6dbb4a2e18
51 files changed
+5395
-287
No files matched your search
@@ -3,6 +3,7 @@ import type {
|
||||
AdminChannelRecord,
|
||||
AdminIoTDevice,
|
||||
AdminLlmConfig,
|
||||
AdminLlmProvider,
|
||||
AdminObservabilityMetrics,
|
||||
AdminPluginRecord,
|
||||
AdminRagHit,
|
||||
@@ -10,12 +11,21 @@ import type {
|
||||
AdminTraceSpan,
|
||||
AdminUserRecord,
|
||||
ApiErrorShape,
|
||||
ApiKeyIssueResult,
|
||||
AuditRecord,
|
||||
AutomationCreateResult,
|
||||
AutomationRunResult,
|
||||
ChannelTestResult,
|
||||
ChatSyncResult,
|
||||
LlmTestRequest,
|
||||
LlmTestResult,
|
||||
LoginResult,
|
||||
MemoryRecord,
|
||||
MemorySearchRequest,
|
||||
MemorySearchResult,
|
||||
Mode,
|
||||
PersonaRecord,
|
||||
PersonaUpsertRequest,
|
||||
Role,
|
||||
SessionRecord,
|
||||
} from "./types";
|
||||
@@ -273,6 +283,137 @@ export function adminDeleteRag(id: string): Promise<{ id: string }> {
|
||||
});
|
||||
}
|
||||
|
||||
/* --- Admin write endpoints (owner-only, audited; real store or honest 501). --- */
|
||||
|
||||
/** POST /api/v1/admin/personas — registers a persona (persisted to YAML + registry). */
|
||||
export function adminCreatePersona(req: PersonaUpsertRequest): Promise<PersonaRecord> {
|
||||
return request<PersonaRecord>("/admin/personas", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** PUT /api/v1/admin/personas/{id} — edits an existing persona. */
|
||||
export function adminUpdatePersona(id: string, req: PersonaUpsertRequest): Promise<PersonaRecord> {
|
||||
return request<PersonaRecord>(`/admin/personas/${encodeURIComponent(id)}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/users — add user/role. No persistent user store yet, so the
|
||||
* backend answers honestly with a 501 ("M10"). */
|
||||
export function adminCreateUser(req: { username: string; role: string }): Promise<AdminUserRecord> {
|
||||
return request<AdminUserRecord>("/admin/users", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/users/apikey — mints a key; the plaintext comes back once. */
|
||||
export function adminIssueApiKey(role: string): Promise<ApiKeyIssueResult> {
|
||||
return request<ApiKeyIssueResult>("/admin/users/apikey", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ role }),
|
||||
});
|
||||
}
|
||||
/** DELETE /api/v1/admin/users/apikey/{id} — revokes a key by masked id. */
|
||||
export function adminRevokeApiKey(id: string): Promise<{ id: string; revoked: boolean }> {
|
||||
return request<{ id: string; revoked: boolean }>(`/admin/users/apikey/${encodeURIComponent(id)}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/iot/{id}/control — sends a control instruction to a device. */
|
||||
export function adminIoTControl(id: string, action: string, params?: Record<string, unknown>): Promise<AdminIoTDevice> {
|
||||
return request<AdminIoTDevice>(`/admin/iot/${encodeURIComponent(id)}/control`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ action, params }),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/iot/scenarios — honest 501 (no scenario store yet). */
|
||||
export function adminIoTScenario(req: { name: string }): Promise<{ name: string }> {
|
||||
return request<{ name: string }>("/admin/iot/scenarios", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** POST /api/v1/admin/iot/rules — honest 501 (no IoT rule store yet). */
|
||||
export function adminIoTRule(req: { name: string; expression: string }): Promise<{ name: string }> {
|
||||
return request<{ name: string }>("/admin/iot/rules", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** POST /api/v1/admin/automations — registers a real cron/event automation. */
|
||||
export function adminCreateAutomation(req: {
|
||||
name: string;
|
||||
kind: string;
|
||||
expression: string;
|
||||
}): Promise<AutomationCreateResult> {
|
||||
return request<AutomationCreateResult>("/admin/automations", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/automations/{id}/run — manually triggers a rule. */
|
||||
export function adminRunAutomation(id: string): Promise<AutomationRunResult> {
|
||||
return request<AutomationRunResult>(`/admin/automations/${encodeURIComponent(id)}/run`, { method: "POST" });
|
||||
}
|
||||
/** DELETE /api/v1/admin/automations/{id} — removes a rule (cron or event). */
|
||||
export function adminDeleteAutomation(id: string): Promise<{ id: string; deleted: boolean }> {
|
||||
return request<{ id: string; deleted: boolean }>(`/admin/automations/${encodeURIComponent(id)}`, { method: "DELETE" });
|
||||
}
|
||||
/** POST /api/v1/admin/llm — records a provider for the process lifetime (temporary). */
|
||||
export function adminAddLlmProvider(req: {
|
||||
id?: string;
|
||||
name: string;
|
||||
baseUrl?: string;
|
||||
model: string;
|
||||
multimodal?: boolean;
|
||||
fallback?: string;
|
||||
}): Promise<{ provider: AdminLlmProvider; temporary: boolean }> {
|
||||
return request<{ provider: AdminLlmProvider; temporary: boolean }>("/admin/llm", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/llm/test — performs a real model call and reports the result. */
|
||||
export function adminTestLlm(req: LlmTestRequest): Promise<LlmTestResult> {
|
||||
return request<LlmTestResult>("/admin/llm/test", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** POST /api/v1/admin/channels/open — connects a registered channel adapter. */
|
||||
export function adminChannelOpen(name: string): Promise<{ name: string; connected: boolean }> {
|
||||
return request<{ name: string; connected: boolean }>("/admin/channels/open", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/channels/close — disconnects a registered channel adapter. */
|
||||
export function adminChannelClose(name: string): Promise<{ name: string; connected: boolean }> {
|
||||
return request<{ name: string; connected: boolean }>("/admin/channels/close", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/channels/test — structural identity test (actor × whitelist). */
|
||||
export function adminChannelTest(req: {
|
||||
platform: string;
|
||||
accountId: string;
|
||||
isGroup: boolean;
|
||||
}): Promise<ChannelTestResult> {
|
||||
return request<ChannelTestResult>("/admin/channels/test", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** POST /api/v1/admin/plugins/install — honest 501 (needs a plugin source). */
|
||||
export function adminPluginInstall(req: { name: string; kind: string; description: string }): Promise<AdminPluginRecord> {
|
||||
return request<AdminPluginRecord>("/admin/plugins/install", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** POST /api/v1/admin/plugins/uninstall — removes a capability from the registry. */
|
||||
export function adminPluginUninstall(req: { name: string }): Promise<{ name: string; uninstalled: boolean }> {
|
||||
return request<{ name: string; uninstalled: boolean }>("/admin/plugins/uninstall", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(req),
|
||||
});
|
||||
}
|
||||
/** POST /api/v1/admin/memories/search — real retrieval over the memory store. */
|
||||
export function adminMemorySearch(req: MemorySearchRequest): Promise<MemorySearchResult> {
|
||||
return request<MemorySearchResult>("/admin/memories/search", { method: "POST", body: JSON.stringify(req) });
|
||||
}
|
||||
/** GET /api/v1/admin/sessions/{id}/export — exports a session as JSON. */
|
||||
export function adminExportSession(id: string): Promise<{ session: SessionRecord }> {
|
||||
return request<{ session: SessionRecord }>(`/admin/sessions/${encodeURIComponent(id)}/export`);
|
||||
}
|
||||
|
||||
/** GET /api/v1/admin/observability/metrics — gateway request metrics. */
|
||||
export function adminObservabilityMetrics(): Promise<AdminObservabilityMetrics> {
|
||||
return request<AdminObservabilityMetrics>("/admin/observability/metrics");
|
||||
|
||||
Reference in new issue
Block a user