@elizaos/ui 2.0.0-alpha.526 → 2.0.0-alpha.528
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/app-elizamaker/src/index.d.ts +2 -0
- package/apps/app-elizamaker/src/index.d.ts.map +1 -1
- package/apps/app-elizamaker/src/index.js +2 -0
- package/apps/app-elizamaker/src/init-registry-services.d.ts +18 -0
- package/apps/app-elizamaker/src/init-registry-services.d.ts.map +1 -0
- package/apps/app-elizamaker/src/init-registry-services.js +63 -0
- package/apps/app-elizamaker/src/plugin.d.ts.map +1 -1
- package/apps/app-elizamaker/src/plugin.js +7 -0
- package/apps/app-elizamaker/src/registry-service-registry.d.ts +4 -0
- package/apps/app-elizamaker/src/registry-service-registry.d.ts.map +1 -0
- package/apps/app-elizamaker/src/registry-service-registry.js +7 -0
- package/apps/app-lifeops/src/automation-node-contributor.d.ts +2 -0
- package/apps/app-lifeops/src/automation-node-contributor.d.ts.map +1 -0
- package/apps/app-lifeops/src/automation-node-contributor.js +93 -0
- package/apps/app-lifeops/src/public.d.ts.map +1 -1
- package/apps/app-lifeops/src/public.js +2 -0
- package/apps/app-training/src/services/training-service-registry.d.ts +4 -0
- package/apps/app-training/src/services/training-service-registry.d.ts.map +1 -0
- package/apps/app-training/src/services/training-service-registry.js +7 -0
- package/package.json +1 -1
- package/packages/agent/src/api/agent-status-routes.d.ts +3 -23
- package/packages/agent/src/api/agent-status-routes.d.ts.map +1 -1
- package/packages/agent/src/api/agent-status-routes.js +7 -40
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +1 -0
- package/packages/agent/src/api/misc-routes.d.ts.map +1 -1
- package/packages/agent/src/api/misc-routes.js +3 -37
- package/packages/agent/src/api/nfa-routes.d.ts.map +1 -1
- package/packages/agent/src/api/nfa-routes.js +1 -9
- package/packages/agent/src/api/provider-switch-routes.d.ts +8 -7
- package/packages/agent/src/api/provider-switch-routes.d.ts.map +1 -1
- package/packages/agent/src/api/provider-switch-routes.js +41 -26
- package/packages/agent/src/api/server-types.d.ts +0 -6
- package/packages/agent/src/api/server-types.d.ts.map +1 -1
- package/packages/agent/src/api/server.d.ts.map +1 -1
- package/packages/agent/src/api/server.js +31 -138
- package/packages/agent/src/api/stream-routes.d.ts.map +1 -1
- package/packages/agent/src/api/stream-routes.js +6 -8
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trading-profile.js +2 -23
- package/packages/agent/src/auth/account-storage.d.ts.map +1 -1
- package/packages/agent/src/auth/account-storage.js +4 -15
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza.js +2 -6
- package/packages/agent/src/runtime/first-time-setup.d.ts.map +1 -1
- package/packages/agent/src/runtime/first-time-setup.js +1 -7
- package/packages/agent/src/runtime/operations/cold-strategy.d.ts +4 -4
- package/packages/agent/src/runtime/operations/cold-strategy.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/cold-strategy.js +13 -46
- package/packages/agent/src/runtime/operations/health-checks.d.ts +1 -0
- package/packages/agent/src/runtime/operations/health-checks.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/health-checks.js +1 -1
- package/packages/agent/src/runtime/operations/health.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/health.js +1 -13
- package/packages/agent/src/runtime/operations/index.d.ts +1 -0
- package/packages/agent/src/runtime/operations/index.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/index.js +1 -0
- package/packages/agent/src/runtime/operations/manager.d.ts +2 -0
- package/packages/agent/src/runtime/operations/manager.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/manager.js +27 -7
- package/packages/agent/src/runtime/operations/reload-hot.d.ts +4 -1
- package/packages/agent/src/runtime/operations/reload-hot.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/reload-hot.js +46 -41
- package/packages/agent/src/runtime/operations/repository.d.ts +30 -8
- package/packages/agent/src/runtime/operations/repository.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/repository.js +140 -54
- package/packages/agent/src/runtime/operations/types.d.ts +26 -24
- package/packages/agent/src/runtime/operations/types.d.ts.map +1 -1
- package/packages/agent/src/runtime/operations/types.js +8 -20
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts +60 -0
- package/packages/agent/src/runtime/operations/vault-bridge.d.ts.map +1 -0
- package/packages/agent/src/runtime/operations/vault-bridge.js +80 -0
- package/packages/agent/src/runtime/plugin-resolver.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-resolver.js +1 -3
- package/packages/agent/src/runtime/plugin-types.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-types.js +1 -3
- package/packages/agent/src/services/app-package-modules.d.ts.map +1 -1
- package/packages/agent/src/services/app-package-modules.js +1 -8
- package/packages/agent/src/services/app-run-store.d.ts.map +1 -1
- package/packages/agent/src/services/app-run-store.js +2 -23
- package/packages/agent/src/services/registry-client-local.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-local.js +1 -9
- package/packages/agent/src/utils/atomic-json.d.ts +37 -0
- package/packages/agent/src/utils/atomic-json.d.ts.map +1 -0
- package/packages/agent/src/utils/atomic-json.js +98 -0
- package/packages/app-core/src/api/automation-node-contributors.d.ts +14 -0
- package/packages/app-core/src/api/automation-node-contributors.d.ts.map +1 -0
- package/packages/app-core/src/api/automation-node-contributors.js +14 -0
- package/packages/app-core/src/api/client-agent.d.ts +627 -0
- package/packages/app-core/src/api/client-agent.d.ts.map +1 -0
- package/packages/app-core/src/api/client-agent.js +1442 -0
- package/packages/app-core/src/api/client-automations.d.ts +8 -0
- package/packages/app-core/src/api/client-automations.d.ts.map +1 -0
- package/packages/app-core/src/api/client-automations.js +7 -0
- package/packages/app-core/src/api/client-base.d.ts +82 -0
- package/packages/app-core/src/api/client-base.d.ts.map +1 -0
- package/packages/app-core/src/api/client-base.js +729 -0
- package/packages/app-core/src/api/client-browser-workspace.d.ts +25 -0
- package/packages/app-core/src/api/client-browser-workspace.d.ts.map +1 -0
- package/packages/app-core/src/api/client-browser-workspace.js +98 -0
- package/packages/app-core/src/api/client-chat.d.ts +355 -0
- package/packages/app-core/src/api/client-chat.d.ts.map +1 -0
- package/packages/app-core/src/api/client-chat.js +582 -0
- package/packages/app-core/src/api/client-cloud.d.ts +286 -0
- package/packages/app-core/src/api/client-cloud.d.ts.map +1 -0
- package/packages/app-core/src/api/client-cloud.js +410 -0
- package/packages/app-core/src/api/client-computeruse.d.ts +32 -0
- package/packages/app-core/src/api/client-computeruse.d.ts.map +1 -0
- package/packages/app-core/src/api/client-computeruse.js +16 -0
- package/packages/app-core/src/api/client-imessage.d.ts +68 -0
- package/packages/app-core/src/api/client-imessage.d.ts.map +1 -0
- package/packages/app-core/src/api/client-imessage.js +74 -0
- package/packages/app-core/src/api/client-local-inference.d.ts +62 -0
- package/packages/app-core/src/api/client-local-inference.d.ts.map +1 -0
- package/packages/app-core/src/api/client-local-inference.js +87 -0
- package/packages/app-core/src/api/client-n8n.d.ts +27 -0
- package/packages/app-core/src/api/client-n8n.d.ts.map +1 -0
- package/packages/app-core/src/api/client-n8n.js +61 -0
- package/packages/app-core/src/api/client-skills.d.ts +475 -0
- package/packages/app-core/src/api/client-skills.d.ts.map +1 -0
- package/packages/app-core/src/api/client-skills.js +608 -0
- package/packages/app-core/src/api/client-types-babylon.d.ts +254 -0
- package/packages/app-core/src/api/client-types-babylon.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-babylon.js +2 -0
- package/packages/app-core/src/api/client-types-character.d.ts +39 -0
- package/packages/app-core/src/api/client-types-character.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-character.js +1 -0
- package/packages/app-core/src/api/client-types-chat.d.ts +428 -0
- package/packages/app-core/src/api/client-types-chat.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-chat.js +9 -0
- package/packages/app-core/src/api/client-types-config.d.ts +587 -0
- package/packages/app-core/src/api/client-types-config.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-config.js +5 -0
- package/packages/app-core/src/api/client-types-experience.d.ts +97 -0
- package/packages/app-core/src/api/client-types-experience.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-experience.js +1 -0
- package/packages/app-core/src/api/client-types-relationships.d.ts +181 -0
- package/packages/app-core/src/api/client-types-relationships.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-relationships.js +1 -0
- package/packages/app-core/src/api/client-types-steward.d.ts +85 -0
- package/packages/app-core/src/api/client-types-steward.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-steward.js +9 -0
- package/packages/app-core/src/api/client-types.d.ts +9 -0
- package/packages/app-core/src/api/client-types.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types.js +12 -0
- package/packages/app-core/src/api/client-wallet.d.ts +130 -0
- package/packages/app-core/src/api/client-wallet.d.ts.map +1 -0
- package/packages/app-core/src/api/client-wallet.js +228 -0
- package/packages/app-core/src/api/client.d.ts +36 -0
- package/packages/app-core/src/api/client.d.ts.map +1 -0
- package/packages/app-core/src/api/client.js +36 -0
- package/packages/app-core/src/api/index.d.ts +2 -0
- package/packages/app-core/src/api/index.d.ts.map +1 -0
- package/packages/app-core/src/api/index.js +1 -0
- package/packages/app-core/src/bridge/electrobun-rpc.d.ts +57 -0
- package/packages/app-core/src/bridge/electrobun-rpc.d.ts.map +1 -0
- package/packages/app-core/src/bridge/electrobun-rpc.js +87 -0
- package/packages/app-core/src/bridge/electrobun-runtime.d.ts +3 -0
- package/packages/app-core/src/bridge/electrobun-runtime.d.ts.map +1 -0
- package/packages/app-core/src/bridge/electrobun-runtime.js +34 -0
- package/packages/app-core/src/bridge/native-plugins.d.ts +504 -0
- package/packages/app-core/src/bridge/native-plugins.d.ts.map +1 -0
- package/packages/app-core/src/bridge/native-plugins.js +67 -0
- package/packages/app-core/src/chat/coding-agent-session-state.d.ts +16 -0
- package/packages/app-core/src/chat/coding-agent-session-state.d.ts.map +1 -0
- package/packages/app-core/src/chat/coding-agent-session-state.js +27 -0
- package/packages/app-core/src/components/pages/browser-workspace-wallet.d.ts +80 -0
- package/packages/app-core/src/components/pages/browser-workspace-wallet.d.ts.map +1 -0
- package/packages/app-core/src/components/pages/browser-workspace-wallet.js +135 -0
- package/packages/app-core/src/services/account-pool.d.ts +98 -0
- package/packages/app-core/src/services/account-pool.d.ts.map +1 -0
- package/packages/app-core/src/services/account-pool.js +506 -0
- package/packages/app-core/src/services/account-usage.d.ts +75 -0
- package/packages/app-core/src/services/account-usage.d.ts.map +1 -0
- package/packages/app-core/src/services/account-usage.js +179 -0
- package/packages/app-core/src/services/local-inference/active-model.d.ts +59 -0
- package/packages/app-core/src/services/local-inference/active-model.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/active-model.js +120 -0
- package/packages/app-core/src/services/local-inference/device-bridge.d.ts +131 -0
- package/packages/app-core/src/services/local-inference/device-bridge.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/device-bridge.js +748 -0
- package/packages/app-core/src/services/local-inference/engine.d.ts +52 -0
- package/packages/app-core/src/services/local-inference/engine.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/engine.js +138 -0
- package/packages/app-core/src/services/local-inference/external-scanner.d.ts +17 -0
- package/packages/app-core/src/services/local-inference/external-scanner.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/external-scanner.js +261 -0
- package/packages/app-core/src/services/local-inference/handler-registry.d.ts +72 -0
- package/packages/app-core/src/services/local-inference/handler-registry.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/handler-registry.js +160 -0
- package/packages/app-core/src/services/local-inference/paths.d.ts +24 -0
- package/packages/app-core/src/services/local-inference/paths.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/paths.js +41 -0
- package/packages/app-core/src/services/local-inference/providers.d.ts +61 -0
- package/packages/app-core/src/services/local-inference/providers.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/providers.js +277 -0
- package/packages/app-core/src/services/local-inference/registry.d.ts +35 -0
- package/packages/app-core/src/services/local-inference/registry.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/registry.js +108 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.d.ts +31 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/routing-preferences.js +72 -0
- package/packages/app-core/src/services/local-inference/types.d.ts +121 -0
- package/packages/app-core/src/services/local-inference/types.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/types.js +14 -0
- package/packages/app-core/src/services/local-inference/verify.d.ts +39 -0
- package/packages/app-core/src/services/local-inference/verify.d.ts.map +1 -0
- package/packages/app-core/src/services/local-inference/verify.js +104 -0
- package/packages/app-core/src/types/index.d.ts +658 -0
- package/packages/app-core/src/types/index.d.ts.map +1 -0
- package/packages/app-core/src/types/index.js +4 -0
- package/packages/app-core/src/utils/assistant-text.d.ts +2 -0
- package/packages/app-core/src/utils/assistant-text.d.ts.map +1 -0
- package/packages/app-core/src/utils/assistant-text.js +167 -0
- package/packages/app-core/src/utils/eliza-globals.d.ts +15 -0
- package/packages/app-core/src/utils/eliza-globals.d.ts.map +1 -0
- package/packages/app-core/src/utils/eliza-globals.js +50 -0
- package/packages/app-core/src/utils/streaming-text.d.ts +9 -0
- package/packages/app-core/src/utils/streaming-text.d.ts.map +1 -0
- package/packages/app-core/src/utils/streaming-text.js +112 -0
- package/packages/shared/src/format-error.d.ts +14 -0
- package/packages/shared/src/format-error.d.ts.map +1 -0
- package/packages/shared/src/format-error.js +17 -0
- package/packages/shared/src/index.d.ts +1 -0
- package/packages/shared/src/index.d.ts.map +1 -1
- package/packages/shared/src/index.js +1 -0
- package/packages/typescript/src/runtime.d.ts +14 -0
- package/packages/typescript/src/runtime.d.ts.map +1 -1
- package/packages/typescript/src/runtime.js +42 -0
- package/packages/typescript/src/services/message.d.ts +8 -0
- package/packages/typescript/src/services/message.d.ts.map +1 -1
- package/packages/typescript/src/services/message.js +51 -0
- package/packages/typescript/src/services/task.d.ts +1 -0
- package/packages/typescript/src/services/task.d.ts.map +1 -1
- package/packages/typescript/src/services/task.js +26 -3
- package/apps/app-task-coordinator/src/api/coordinator-wiring.d.ts.map +0 -1
- /package/{apps/app-task-coordinator → packages/agent}/src/api/coordinator-wiring.d.ts +0 -0
- /package/{apps/app-task-coordinator → packages/agent}/src/api/coordinator-wiring.js +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-registry of model handlers registered on an AgentRuntime.
|
|
3
|
+
*
|
|
4
|
+
* The elizaOS core exposes `runtime.registerModel(type, handler, provider,
|
|
5
|
+
* priority)` but no way to list who registered what. This module intercepts
|
|
6
|
+
* `registerModel` at runtime to record every registration in a Map keyed by
|
|
7
|
+
* model type, plus fires status listeners so the UI can render a live
|
|
8
|
+
* [ModelType × Provider] routing table.
|
|
9
|
+
*
|
|
10
|
+
* Because we monkey-patch `registerModel` we also keep the original
|
|
11
|
+
* handler reference — the router-handler (see `router-handler.ts`) uses
|
|
12
|
+
* this to dispatch inference calls by policy without going through
|
|
13
|
+
* `runtime.useModel` (which would loop back to us and recurse).
|
|
14
|
+
*/
|
|
15
|
+
import { AgentRuntime } from "@elizaos/core";
|
|
16
|
+
class HandlerRegistry {
|
|
17
|
+
registrations = new Map();
|
|
18
|
+
listeners = new Set();
|
|
19
|
+
installedOn = new WeakSet();
|
|
20
|
+
/**
|
|
21
|
+
* Snapshot of all registrations grouped by model type, sorted by
|
|
22
|
+
* priority descending inside each group (matches core's selection
|
|
23
|
+
* order). Callers must not mutate the returned array.
|
|
24
|
+
*/
|
|
25
|
+
getAll() {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const list of this.registrations.values()) {
|
|
28
|
+
out.push(...list);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** All registrations for a given model type, sorted by priority desc. */
|
|
33
|
+
getForType(modelType) {
|
|
34
|
+
const list = this.registrations.get(modelType);
|
|
35
|
+
return list ? [...list] : [];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Registrations excluding a specific provider. Used by the router-handler
|
|
39
|
+
* to find "all providers except me" when dispatching.
|
|
40
|
+
*/
|
|
41
|
+
getForTypeExcluding(modelType, excludeProvider) {
|
|
42
|
+
return this.getForType(modelType).filter((r) => r.provider !== excludeProvider);
|
|
43
|
+
}
|
|
44
|
+
subscribe(listener) {
|
|
45
|
+
this.listeners.add(listener);
|
|
46
|
+
return () => {
|
|
47
|
+
this.listeners.delete(listener);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
emit() {
|
|
51
|
+
const snapshot = this.getAll();
|
|
52
|
+
for (const listener of this.listeners) {
|
|
53
|
+
try {
|
|
54
|
+
listener(snapshot);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
this.listeners.delete(listener);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
record(reg) {
|
|
62
|
+
const existing = this.registrations.get(reg.modelType) ?? [];
|
|
63
|
+
// Replace any prior registration from the same provider for this
|
|
64
|
+
// model type. Core allows multiple providers per type but only one
|
|
65
|
+
// registration per (type, provider) pair — last write wins.
|
|
66
|
+
const filtered = existing.filter((r) => r.provider !== reg.provider);
|
|
67
|
+
filtered.push(reg);
|
|
68
|
+
filtered.sort((a, b) => b.priority - a.priority);
|
|
69
|
+
this.registrations.set(reg.modelType, filtered);
|
|
70
|
+
this.emit();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Install the interception on a runtime. Idempotent per runtime instance.
|
|
74
|
+
* For most boot paths the prototype-level patch below already covers the
|
|
75
|
+
* runtime before any plugin registers; this method is the belt-and-braces
|
|
76
|
+
* fallback for runtimes constructed before the patch ran.
|
|
77
|
+
*/
|
|
78
|
+
installOn(runtime) {
|
|
79
|
+
installPrototypePatch();
|
|
80
|
+
const rt = runtime;
|
|
81
|
+
if (typeof rt.registerModel !== "function")
|
|
82
|
+
return;
|
|
83
|
+
if (this.installedOn.has(rt))
|
|
84
|
+
return;
|
|
85
|
+
this.installedOn.add(rt);
|
|
86
|
+
// If the runtime already inherited the patched prototype method the
|
|
87
|
+
// prototype handles every call. Nothing to do per-instance.
|
|
88
|
+
const protoMethod = Object.getPrototypeOf(rt)?.registerModel;
|
|
89
|
+
if (protoMethod &&
|
|
90
|
+
protoMethod[PATCH_MARK]) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Per-instance wrap only for legacy runtimes whose prototype pre-dates
|
|
94
|
+
// our prototype patch (shouldn't happen in practice).
|
|
95
|
+
const original = rt.registerModel.bind(runtime);
|
|
96
|
+
rt.registerModel = ((modelType, handler, provider, priority) => {
|
|
97
|
+
this.record({
|
|
98
|
+
modelType: String(modelType),
|
|
99
|
+
provider: String(provider),
|
|
100
|
+
priority: typeof priority === "number" ? priority : 0,
|
|
101
|
+
registeredAt: new Date().toISOString(),
|
|
102
|
+
handler,
|
|
103
|
+
});
|
|
104
|
+
return original(modelType, handler, provider, priority);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Exposed so the prototype patch can record through the singleton. */
|
|
108
|
+
recordFromPrototype(reg) {
|
|
109
|
+
this.record(reg);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const PATCH_MARK = Symbol.for("milady.local-inference.registerModel.patched");
|
|
113
|
+
let prototypePatched = false;
|
|
114
|
+
/**
|
|
115
|
+
* One-shot patch of `AgentRuntime.prototype.registerModel` so every runtime
|
|
116
|
+
* instance — including ones constructed later in boot — records through
|
|
117
|
+
* the singleton handler registry. Idempotent.
|
|
118
|
+
*/
|
|
119
|
+
function installPrototypePatch() {
|
|
120
|
+
if (prototypePatched)
|
|
121
|
+
return;
|
|
122
|
+
const proto = AgentRuntime.prototype;
|
|
123
|
+
const original = proto.registerModel;
|
|
124
|
+
if (typeof original !== "function")
|
|
125
|
+
return;
|
|
126
|
+
if (original[PATCH_MARK]) {
|
|
127
|
+
prototypePatched = true;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const patched = function patchedRegisterModel(modelType, handler, provider, priority) {
|
|
131
|
+
try {
|
|
132
|
+
handlerRegistry.recordFromPrototype({
|
|
133
|
+
modelType: String(modelType),
|
|
134
|
+
provider: String(provider),
|
|
135
|
+
priority: typeof priority === "number" ? priority : 0,
|
|
136
|
+
registeredAt: new Date().toISOString(),
|
|
137
|
+
handler,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// Never let registry bookkeeping break the registration path.
|
|
142
|
+
}
|
|
143
|
+
original.call(this, modelType, handler, provider, priority);
|
|
144
|
+
};
|
|
145
|
+
patched[PATCH_MARK] = true;
|
|
146
|
+
proto.registerModel = patched;
|
|
147
|
+
prototypePatched = true;
|
|
148
|
+
}
|
|
149
|
+
// Install at module-import time. This is a process-wide side effect but a
|
|
150
|
+
// benign one: the patch is idempotent and forwards to the original.
|
|
151
|
+
installPrototypePatch();
|
|
152
|
+
export const handlerRegistry = new HandlerRegistry();
|
|
153
|
+
export function toPublicRegistration(reg) {
|
|
154
|
+
return {
|
|
155
|
+
modelType: reg.modelType,
|
|
156
|
+
provider: reg.provider,
|
|
157
|
+
priority: reg.priority,
|
|
158
|
+
registeredAt: reg.registeredAt,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution for the local-inference service.
|
|
3
|
+
*
|
|
4
|
+
* All Milady-owned files live under `$STATE_DIR/local-inference/` to match
|
|
5
|
+
* the convention established by `plugin-installer.ts` and the rest of
|
|
6
|
+
* app-core. We never write to paths outside of this root.
|
|
7
|
+
*
|
|
8
|
+
* The state dir is resolved in `MILADY_STATE_DIR` → `ELIZA_STATE_DIR` →
|
|
9
|
+
* `~/.eliza` order. The `.eliza` fallback is preserved for desktop
|
|
10
|
+
* backward-compat with existing installs; on AOSP `MILADY_STATE_DIR` is
|
|
11
|
+
* set by `MiladyAgentService.java` to `/data/data/<pkg>/files/.milady`,
|
|
12
|
+
* so models land at `<that>/local-inference/models/` and not under a
|
|
13
|
+
* stray homedir-derived path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function localInferenceRoot(): string;
|
|
16
|
+
/** Directory for models Milady downloaded itself. Safe to delete. */
|
|
17
|
+
export declare function miladyModelsDir(): string;
|
|
18
|
+
/** JSON file tracking installed-model metadata (downloaded + discovered). */
|
|
19
|
+
export declare function registryPath(): string;
|
|
20
|
+
/** Partial-download staging directory; files here are resume candidates. */
|
|
21
|
+
export declare function downloadsStagingDir(): string;
|
|
22
|
+
/** True when `target` is inside Milady's local-inference root. */
|
|
23
|
+
export declare function isWithinMiladyRoot(target: string): boolean;
|
|
24
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../../../../app-core/src/services/local-inference/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,wBAAgB,kBAAkB,IAAI,MAAM,CAK3C;AAED,qEAAqE;AACrE,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAK1D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution for the local-inference service.
|
|
3
|
+
*
|
|
4
|
+
* All Milady-owned files live under `$STATE_DIR/local-inference/` to match
|
|
5
|
+
* the convention established by `plugin-installer.ts` and the rest of
|
|
6
|
+
* app-core. We never write to paths outside of this root.
|
|
7
|
+
*
|
|
8
|
+
* The state dir is resolved in `MILADY_STATE_DIR` → `ELIZA_STATE_DIR` →
|
|
9
|
+
* `~/.eliza` order. The `.eliza` fallback is preserved for desktop
|
|
10
|
+
* backward-compat with existing installs; on AOSP `MILADY_STATE_DIR` is
|
|
11
|
+
* set by `MiladyAgentService.java` to `/data/data/<pkg>/files/.milady`,
|
|
12
|
+
* so models land at `<that>/local-inference/models/` and not under a
|
|
13
|
+
* stray homedir-derived path.
|
|
14
|
+
*/
|
|
15
|
+
import os from "node:os";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
export function localInferenceRoot() {
|
|
18
|
+
const stateDir = process.env.MILADY_STATE_DIR?.trim() || process.env.ELIZA_STATE_DIR?.trim();
|
|
19
|
+
const base = stateDir || path.join(os.homedir(), ".eliza");
|
|
20
|
+
return path.join(base, "local-inference");
|
|
21
|
+
}
|
|
22
|
+
/** Directory for models Milady downloaded itself. Safe to delete. */
|
|
23
|
+
export function miladyModelsDir() {
|
|
24
|
+
return path.join(localInferenceRoot(), "models");
|
|
25
|
+
}
|
|
26
|
+
/** JSON file tracking installed-model metadata (downloaded + discovered). */
|
|
27
|
+
export function registryPath() {
|
|
28
|
+
return path.join(localInferenceRoot(), "registry.json");
|
|
29
|
+
}
|
|
30
|
+
/** Partial-download staging directory; files here are resume candidates. */
|
|
31
|
+
export function downloadsStagingDir() {
|
|
32
|
+
return path.join(localInferenceRoot(), "downloads");
|
|
33
|
+
}
|
|
34
|
+
/** True when `target` is inside Milady's local-inference root. */
|
|
35
|
+
export function isWithinMiladyRoot(target) {
|
|
36
|
+
const root = path.resolve(localInferenceRoot());
|
|
37
|
+
const resolved = path.resolve(target);
|
|
38
|
+
if (resolved === root)
|
|
39
|
+
return false;
|
|
40
|
+
return resolved.startsWith(`${root}${path.sep}`);
|
|
41
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider registry.
|
|
3
|
+
*
|
|
4
|
+
* Treats every inference source the same way — cloud subscription, cloud
|
|
5
|
+
* API, local llama.cpp engine, paired-device bridge, Capacitor on-device
|
|
6
|
+
* — each is a `ProviderDefinition` with an `id`, a human label, a set of
|
|
7
|
+
* supported model slots, and a pluggable `getEnableState()` that inspects
|
|
8
|
+
* whatever underlying gate controls it (API key presence, subscription
|
|
9
|
+
* status, env flag, file on disk).
|
|
10
|
+
*
|
|
11
|
+
* The cloud-provider status readers are intentionally permissive: they
|
|
12
|
+
* report what they can introspect without depending on the specific
|
|
13
|
+
* cloud-plugin internals, and hand off to the existing ProviderSwitcher
|
|
14
|
+
* UI for actual enable/disable via `configureHref`. That avoids the
|
|
15
|
+
* "combined enable matrix is an architectural project" problem by making
|
|
16
|
+
* configuration navigable rather than centralised.
|
|
17
|
+
*/
|
|
18
|
+
import type { AgentModelSlot } from "./types";
|
|
19
|
+
export type ProviderId = "milady-local-inference" | "milady-device-bridge" | "capacitor-llama" | "anthropic-subscription" | "openai-codex" | "anthropic" | "openai" | "grok" | "elizacloud" | "google" | "mistral";
|
|
20
|
+
export interface ProviderEnableState {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** Short reason, e.g. "API key set", "Device connected", "No API key". */
|
|
23
|
+
reason: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ProviderDefinition {
|
|
26
|
+
id: ProviderId;
|
|
27
|
+
label: string;
|
|
28
|
+
kind: "cloud-api" | "cloud-subscription" | "local" | "device-bridge";
|
|
29
|
+
/** Short blurb shown in the UI. */
|
|
30
|
+
description: string;
|
|
31
|
+
/** Agent slots this provider can plausibly serve. */
|
|
32
|
+
supportedSlots: AgentModelSlot[];
|
|
33
|
+
/**
|
|
34
|
+
* Read the current enable state. For cloud providers we inspect env
|
|
35
|
+
* vars or config fragments; for local we check file presence; for
|
|
36
|
+
* device-bridge we check connected-device count.
|
|
37
|
+
*/
|
|
38
|
+
getEnableState(): Promise<ProviderEnableState>;
|
|
39
|
+
/**
|
|
40
|
+
* Link to the settings UI where enable/configure actually happens.
|
|
41
|
+
* UI sends the user here via anchor-scroll when they click "Configure".
|
|
42
|
+
* `null` means the provider has no separate config surface.
|
|
43
|
+
*/
|
|
44
|
+
configureHref: string | null;
|
|
45
|
+
}
|
|
46
|
+
/** Resolve which slots have at least one registered handler from this provider. */
|
|
47
|
+
export declare function getRegisteredSlotsForProvider(providerId: string): string[];
|
|
48
|
+
export declare const BUILT_IN_PROVIDERS: readonly ProviderDefinition[];
|
|
49
|
+
export interface ProviderStatus {
|
|
50
|
+
id: ProviderId;
|
|
51
|
+
label: string;
|
|
52
|
+
kind: ProviderDefinition["kind"];
|
|
53
|
+
description: string;
|
|
54
|
+
supportedSlots: AgentModelSlot[];
|
|
55
|
+
configureHref: string | null;
|
|
56
|
+
enableState: ProviderEnableState;
|
|
57
|
+
/** Registered model types this provider has handlers for, right now. */
|
|
58
|
+
registeredSlots: string[];
|
|
59
|
+
}
|
|
60
|
+
export declare function snapshotProviders(): Promise<ProviderStatus[]>;
|
|
61
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../../../../app-core/src/services/local-inference/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,UAAU,GAClB,wBAAwB,GACxB,sBAAsB,GACtB,iBAAiB,GACjB,wBAAwB,GACxB,cAAc,GACd,WAAW,GACX,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,WAAW,GAAG,oBAAoB,GAAG,OAAO,GAAG,eAAe,CAAC;IACrE,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC;;;;OAIG;IACH,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/C;;;;OAIG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,mFAAmF;AACnF,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAO1E;AAiOD,eAAO,MAAM,kBAAkB,EAAE,SAAS,kBAAkB,EAY3D,CAAC;AAqBF,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,mBAAmB,CAAC;IACjC,wEAAwE;IACxE,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAiBnE"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider registry.
|
|
3
|
+
*
|
|
4
|
+
* Treats every inference source the same way — cloud subscription, cloud
|
|
5
|
+
* API, local llama.cpp engine, paired-device bridge, Capacitor on-device
|
|
6
|
+
* — each is a `ProviderDefinition` with an `id`, a human label, a set of
|
|
7
|
+
* supported model slots, and a pluggable `getEnableState()` that inspects
|
|
8
|
+
* whatever underlying gate controls it (API key presence, subscription
|
|
9
|
+
* status, env flag, file on disk).
|
|
10
|
+
*
|
|
11
|
+
* The cloud-provider status readers are intentionally permissive: they
|
|
12
|
+
* report what they can introspect without depending on the specific
|
|
13
|
+
* cloud-plugin internals, and hand off to the existing ProviderSwitcher
|
|
14
|
+
* UI for actual enable/disable via `configureHref`. That avoids the
|
|
15
|
+
* "combined enable matrix is an architectural project" problem by making
|
|
16
|
+
* configuration navigable rather than centralised.
|
|
17
|
+
*/
|
|
18
|
+
import fs from "node:fs/promises";
|
|
19
|
+
import { getDefaultAccountPool } from "../account-pool";
|
|
20
|
+
import { deviceBridge } from "./device-bridge";
|
|
21
|
+
import { handlerRegistry } from "./handler-registry";
|
|
22
|
+
import { localInferenceRoot } from "./paths";
|
|
23
|
+
/** Resolve which slots have at least one registered handler from this provider. */
|
|
24
|
+
export function getRegisteredSlotsForProvider(providerId) {
|
|
25
|
+
const regs = handlerRegistry.getAll();
|
|
26
|
+
const slots = new Set();
|
|
27
|
+
for (const r of regs) {
|
|
28
|
+
if (r.provider === providerId)
|
|
29
|
+
slots.add(r.modelType);
|
|
30
|
+
}
|
|
31
|
+
return [...slots];
|
|
32
|
+
}
|
|
33
|
+
// ── Built-in provider definitions ────────────────────────────────────
|
|
34
|
+
const LOCAL_PROVIDER = {
|
|
35
|
+
id: "milady-local-inference",
|
|
36
|
+
label: "Local llama.cpp",
|
|
37
|
+
kind: "local",
|
|
38
|
+
description: "On-device inference using node-llama-cpp. Free, private, runs on your machine's CPU/GPU.",
|
|
39
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE"],
|
|
40
|
+
async getEnableState() {
|
|
41
|
+
// Enabled when at least one model file lives under our root and the
|
|
42
|
+
// binding is loadable. We don't force-load node-llama-cpp here — that
|
|
43
|
+
// would tie up GPU memory just for a status probe.
|
|
44
|
+
try {
|
|
45
|
+
const entries = await fs.readdir(`${localInferenceRoot()}/models`, {
|
|
46
|
+
withFileTypes: true,
|
|
47
|
+
});
|
|
48
|
+
const hasModel = entries.some((e) => e.isFile() && e.name.toLowerCase().endsWith(".gguf"));
|
|
49
|
+
return hasModel
|
|
50
|
+
? { enabled: true, reason: "GGUF model installed" }
|
|
51
|
+
: { enabled: false, reason: "No local model installed" };
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return { enabled: false, reason: "No local model installed" };
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
configureHref: "#local-inference-panel",
|
|
58
|
+
};
|
|
59
|
+
const DEVICE_BRIDGE_PROVIDER = {
|
|
60
|
+
id: "milady-device-bridge",
|
|
61
|
+
label: "Paired device bridge",
|
|
62
|
+
kind: "device-bridge",
|
|
63
|
+
description: "Inference on a paired mobile or desktop device over WebSocket. Useful when the agent runs in a container but the model lives on your phone or laptop.",
|
|
64
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE"],
|
|
65
|
+
async getEnableState() {
|
|
66
|
+
const bridgeEnabled = process.env.ELIZA_DEVICE_BRIDGE_ENABLED?.trim() === "1";
|
|
67
|
+
if (!bridgeEnabled) {
|
|
68
|
+
return {
|
|
69
|
+
enabled: false,
|
|
70
|
+
reason: "Set ELIZA_DEVICE_BRIDGE_ENABLED=1 to enable",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const status = deviceBridge.status();
|
|
74
|
+
if (status.connected) {
|
|
75
|
+
return {
|
|
76
|
+
enabled: true,
|
|
77
|
+
reason: `${status.devices.length} device(s) connected`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
enabled: true,
|
|
82
|
+
reason: "Waiting for a device to connect",
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
configureHref: "#device-bridge-status",
|
|
86
|
+
};
|
|
87
|
+
const CAPACITOR_LLAMA_PROVIDER = {
|
|
88
|
+
id: "capacitor-llama",
|
|
89
|
+
label: "On-device llama.cpp (mobile)",
|
|
90
|
+
kind: "local",
|
|
91
|
+
description: "Runs llama.cpp natively on iOS or Android via Capacitor. Only available in mobile builds.",
|
|
92
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE"],
|
|
93
|
+
async getEnableState() {
|
|
94
|
+
const cap = globalThis.Capacitor;
|
|
95
|
+
if (cap?.isNativePlatform?.()) {
|
|
96
|
+
return {
|
|
97
|
+
enabled: true,
|
|
98
|
+
reason: "Native Capacitor runtime detected",
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
enabled: false,
|
|
103
|
+
reason: "Only available in iOS/Android builds",
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
configureHref: null,
|
|
107
|
+
};
|
|
108
|
+
const ANTHROPIC_PROVIDER = {
|
|
109
|
+
id: "anthropic",
|
|
110
|
+
label: "Anthropic API",
|
|
111
|
+
kind: "cloud-api",
|
|
112
|
+
description: "Claude models via the Anthropic API. Requires an API key.",
|
|
113
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE", "OBJECT_SMALL", "OBJECT_LARGE"],
|
|
114
|
+
async getEnableState() {
|
|
115
|
+
const key = process.env.ANTHROPIC_API_KEY?.trim();
|
|
116
|
+
return key
|
|
117
|
+
? { enabled: true, reason: "API key set" }
|
|
118
|
+
: { enabled: false, reason: "No API key" };
|
|
119
|
+
},
|
|
120
|
+
configureHref: "#ai-model",
|
|
121
|
+
};
|
|
122
|
+
const OPENAI_PROVIDER = {
|
|
123
|
+
id: "openai",
|
|
124
|
+
label: "OpenAI API",
|
|
125
|
+
kind: "cloud-api",
|
|
126
|
+
description: "GPT models via the OpenAI API. Requires an API key.",
|
|
127
|
+
supportedSlots: [
|
|
128
|
+
"TEXT_SMALL",
|
|
129
|
+
"TEXT_LARGE",
|
|
130
|
+
"TEXT_EMBEDDING",
|
|
131
|
+
"OBJECT_SMALL",
|
|
132
|
+
"OBJECT_LARGE",
|
|
133
|
+
],
|
|
134
|
+
async getEnableState() {
|
|
135
|
+
const key = process.env.OPENAI_API_KEY?.trim();
|
|
136
|
+
return key
|
|
137
|
+
? { enabled: true, reason: "API key set" }
|
|
138
|
+
: { enabled: false, reason: "No API key" };
|
|
139
|
+
},
|
|
140
|
+
configureHref: "#ai-model",
|
|
141
|
+
};
|
|
142
|
+
const GROK_PROVIDER = {
|
|
143
|
+
id: "grok",
|
|
144
|
+
label: "Grok API",
|
|
145
|
+
kind: "cloud-api",
|
|
146
|
+
description: "xAI Grok models. Requires an API key.",
|
|
147
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE"],
|
|
148
|
+
async getEnableState() {
|
|
149
|
+
const key = process.env.GROK_API_KEY?.trim() ?? process.env.XAI_API_KEY?.trim();
|
|
150
|
+
return key
|
|
151
|
+
? { enabled: true, reason: "API key set" }
|
|
152
|
+
: { enabled: false, reason: "No API key" };
|
|
153
|
+
},
|
|
154
|
+
configureHref: "#ai-model",
|
|
155
|
+
};
|
|
156
|
+
const ELIZACLOUD_PROVIDER = {
|
|
157
|
+
id: "elizacloud",
|
|
158
|
+
label: "Eliza Cloud",
|
|
159
|
+
kind: "cloud-subscription",
|
|
160
|
+
description: "Milady-hosted inference routed through your subscription. No API key to manage.",
|
|
161
|
+
supportedSlots: [
|
|
162
|
+
"TEXT_SMALL",
|
|
163
|
+
"TEXT_LARGE",
|
|
164
|
+
"TEXT_EMBEDDING",
|
|
165
|
+
"OBJECT_SMALL",
|
|
166
|
+
"OBJECT_LARGE",
|
|
167
|
+
],
|
|
168
|
+
async getEnableState() {
|
|
169
|
+
const token = process.env.ELIZA_CLOUD_TOKEN?.trim() ??
|
|
170
|
+
process.env.ELIZACLOUD_TOKEN?.trim() ??
|
|
171
|
+
process.env.ELIZAOS_API_KEY?.trim();
|
|
172
|
+
return token
|
|
173
|
+
? { enabled: true, reason: "Cloud token set" }
|
|
174
|
+
: { enabled: false, reason: "Not signed in" };
|
|
175
|
+
},
|
|
176
|
+
configureHref: "#ai-model",
|
|
177
|
+
};
|
|
178
|
+
const ANTHROPIC_SUBSCRIPTION_PROVIDER = {
|
|
179
|
+
id: "anthropic-subscription",
|
|
180
|
+
label: "Claude subscription",
|
|
181
|
+
kind: "cloud-subscription",
|
|
182
|
+
description: "Claude Code task-agent access through linked accounts.",
|
|
183
|
+
// Claude.ai OAuth subscriptions serve text + structured-object generation
|
|
184
|
+
// through Anthropic's chat models. Embeddings are not exposed by the
|
|
185
|
+
// subscription path (Anthropic does not ship an embeddings endpoint), so
|
|
186
|
+
// TEXT_EMBEDDING is intentionally omitted — that slot needs a separate
|
|
187
|
+
// API-key provider.
|
|
188
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE", "OBJECT_SMALL", "OBJECT_LARGE"],
|
|
189
|
+
async getEnableState() {
|
|
190
|
+
return subscriptionEnableState("anthropic-subscription");
|
|
191
|
+
},
|
|
192
|
+
configureHref: "#ai-model",
|
|
193
|
+
};
|
|
194
|
+
const OPENAI_CODEX_PROVIDER = {
|
|
195
|
+
id: "openai-codex",
|
|
196
|
+
label: "Codex subscription",
|
|
197
|
+
kind: "cloud-subscription",
|
|
198
|
+
description: "Codex and ChatGPT subscription access through linked accounts.",
|
|
199
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE", "OBJECT_SMALL", "OBJECT_LARGE"],
|
|
200
|
+
async getEnableState() {
|
|
201
|
+
return subscriptionEnableState("openai-codex");
|
|
202
|
+
},
|
|
203
|
+
configureHref: "#ai-model",
|
|
204
|
+
};
|
|
205
|
+
const GOOGLE_PROVIDER = {
|
|
206
|
+
id: "google",
|
|
207
|
+
label: "Google (Gemini)",
|
|
208
|
+
kind: "cloud-api",
|
|
209
|
+
description: "Gemini models via Google Generative AI. Requires an API key.",
|
|
210
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE", "OBJECT_SMALL", "OBJECT_LARGE"],
|
|
211
|
+
async getEnableState() {
|
|
212
|
+
const key = process.env.GOOGLE_API_KEY?.trim() ?? process.env.GEMINI_API_KEY?.trim();
|
|
213
|
+
return key
|
|
214
|
+
? { enabled: true, reason: "API key set" }
|
|
215
|
+
: { enabled: false, reason: "No API key" };
|
|
216
|
+
},
|
|
217
|
+
configureHref: "#ai-model",
|
|
218
|
+
};
|
|
219
|
+
const MISTRAL_PROVIDER = {
|
|
220
|
+
id: "mistral",
|
|
221
|
+
label: "Mistral API",
|
|
222
|
+
kind: "cloud-api",
|
|
223
|
+
description: "Mistral models via la Plateforme. Requires an API key.",
|
|
224
|
+
supportedSlots: ["TEXT_SMALL", "TEXT_LARGE"],
|
|
225
|
+
async getEnableState() {
|
|
226
|
+
const key = process.env.MISTRAL_API_KEY?.trim();
|
|
227
|
+
return key
|
|
228
|
+
? { enabled: true, reason: "API key set" }
|
|
229
|
+
: { enabled: false, reason: "No API key" };
|
|
230
|
+
},
|
|
231
|
+
configureHref: "#ai-model",
|
|
232
|
+
};
|
|
233
|
+
export const BUILT_IN_PROVIDERS = [
|
|
234
|
+
LOCAL_PROVIDER,
|
|
235
|
+
DEVICE_BRIDGE_PROVIDER,
|
|
236
|
+
CAPACITOR_LLAMA_PROVIDER,
|
|
237
|
+
ANTHROPIC_SUBSCRIPTION_PROVIDER,
|
|
238
|
+
OPENAI_CODEX_PROVIDER,
|
|
239
|
+
ELIZACLOUD_PROVIDER,
|
|
240
|
+
ANTHROPIC_PROVIDER,
|
|
241
|
+
OPENAI_PROVIDER,
|
|
242
|
+
GOOGLE_PROVIDER,
|
|
243
|
+
GROK_PROVIDER,
|
|
244
|
+
MISTRAL_PROVIDER,
|
|
245
|
+
];
|
|
246
|
+
function subscriptionEnableState(providerId) {
|
|
247
|
+
if (providerId !== "anthropic-subscription" &&
|
|
248
|
+
providerId !== "openai-codex") {
|
|
249
|
+
return { enabled: false, reason: "Unsupported subscription" };
|
|
250
|
+
}
|
|
251
|
+
const accounts = getDefaultAccountPool()
|
|
252
|
+
.list(providerId)
|
|
253
|
+
.filter((account) => account.enabled && account.health === "ok");
|
|
254
|
+
if (accounts.length === 0) {
|
|
255
|
+
return { enabled: false, reason: "No linked account" };
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
enabled: true,
|
|
259
|
+
reason: `${accounts.length} linked account${accounts.length === 1 ? "" : "s"}`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export async function snapshotProviders() {
|
|
263
|
+
const entries = await Promise.all(BUILT_IN_PROVIDERS.map(async (def) => {
|
|
264
|
+
const state = await def.getEnableState();
|
|
265
|
+
return {
|
|
266
|
+
id: def.id,
|
|
267
|
+
label: def.label,
|
|
268
|
+
kind: def.kind,
|
|
269
|
+
description: def.description,
|
|
270
|
+
supportedSlots: def.supportedSlots,
|
|
271
|
+
configureHref: def.configureHref,
|
|
272
|
+
enableState: state,
|
|
273
|
+
registeredSlots: getRegisteredSlotsForProvider(def.id),
|
|
274
|
+
};
|
|
275
|
+
}));
|
|
276
|
+
return entries;
|
|
277
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-disk registry of installed models.
|
|
3
|
+
*
|
|
4
|
+
* Two sources feed the registry:
|
|
5
|
+
* 1. Milady-owned downloads (source: "milady-download") — written on
|
|
6
|
+
* successful completion by the downloader.
|
|
7
|
+
* 2. External scans (source: "external-scan") — merged in at read time
|
|
8
|
+
* from `scanExternalModels()`. These are never persisted to the
|
|
9
|
+
* registry file; a rescan runs whenever we read.
|
|
10
|
+
*
|
|
11
|
+
* The JSON file only holds Milady-owned entries. That way, if a user
|
|
12
|
+
* cleans up LM Studio models we don't show stale ghosts.
|
|
13
|
+
*/
|
|
14
|
+
import type { InstalledModel } from "./types";
|
|
15
|
+
/**
|
|
16
|
+
* Return all models currently usable: persisted Milady downloads plus a
|
|
17
|
+
* fresh external-tool scan. External duplicates of Milady-owned files are
|
|
18
|
+
* filtered out by path.
|
|
19
|
+
*/
|
|
20
|
+
export declare function listInstalledModels(): Promise<InstalledModel[]>;
|
|
21
|
+
/** Add or update a Milady-owned entry. External entries are rejected. */
|
|
22
|
+
export declare function upsertMiladyModel(model: InstalledModel): Promise<void>;
|
|
23
|
+
/** Mark an existing Milady-owned model as most-recently-used. */
|
|
24
|
+
export declare function touchMiladyModel(id: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete a Milady-owned model from the registry and from disk.
|
|
27
|
+
*
|
|
28
|
+
* Refuses if the model was discovered from another tool — Milady must not
|
|
29
|
+
* touch files it doesn't own. Callers surface that refusal as a 4xx.
|
|
30
|
+
*/
|
|
31
|
+
export declare function removeMiladyModel(id: string): Promise<{
|
|
32
|
+
removed: boolean;
|
|
33
|
+
reason?: "external" | "not-found";
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../../app-core/src/services/local-inference/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAmC9C;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAcrE;AAED,yEAAyE;AACzE,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5E;AAED,iEAAiE;AACjE,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACnC,CAAC,CAyBD"}
|