@elizaos/capacitor-bun-runtime 2.0.11-beta.7
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/ElizaosCapacitorBunRuntime.podspec +54 -0
- package/LICENSE +21 -0
- package/README.md +127 -0
- package/dist/esm/definitions.d.ts +136 -0
- package/dist/esm/definitions.d.ts.map +1 -0
- package/dist/esm/definitions.js +14 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +19 -0
- package/dist/esm/web.d.ts.map +1 -0
- package/dist/esm/web.js +44 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +63 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +66 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/ElizaBunRuntimePlugin/BridgeInstaller.swift +94 -0
- package/ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntime.swift +705 -0
- package/ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntimePlugin.swift +1109 -0
- package/ios/Sources/ElizaBunRuntimePlugin/FullBunEngineHost.swift +677 -0
- package/ios/Sources/ElizaBunRuntimePlugin/JSContextHelpers.swift +226 -0
- package/ios/Sources/ElizaBunRuntimePlugin/SandboxPaths.swift +46 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/CryptoBridge.swift +238 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/ElizaSqliteVecBridge.m +28 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/FSBridge.swift +270 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/HTTPBridge.swift +153 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/HTTPServerBridge.swift +32 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/LlamaBridge.swift +233 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/LlamaBridgeImpl.swift +1863 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/LogBridge.swift +36 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/PathsBridge.swift +41 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/ProcessBridge.swift +80 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteBridge.swift +406 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteBridgeInstaller.swift +17 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteVecLoader.swift +66 -0
- package/ios/Sources/ElizaBunRuntimePlugin/bridge/UIBridge.swift +72 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlChinesePhonemizer.swift +313 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlConfiguration.swift +28 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlEngine.swift +325 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlHindiPhonemizer.swift +150 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlJapanesePhonemizer.swift +209 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlLatinPhonemizer.swift +374 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlModel.swift +87 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlPhonemizer.swift +679 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlPronunciationDicts.swift +131 -0
- package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlSupport.swift +24 -0
- package/ios/Tests/llama-bridge-smoke-main.swift +92 -0
- package/package.json +68 -0
- package/src/bridge-contract.test.ts +127 -0
- package/src/definitions.d.ts +136 -0
- package/src/definitions.d.ts.map +1 -0
- package/src/definitions.ts +152 -0
- package/src/index.d.ts +9 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +16 -0
- package/src/web.d.ts +19 -0
- package/src/web.d.ts.map +1 -0
- package/src/web.ts +80 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @elizaos/capacitor-bun-runtime — iOS embedded Bun-shape JS runtime.
|
|
3
|
+
*
|
|
4
|
+
* Hosts a JavaScriptCore JSContext on a dedicated worker thread. The native
|
|
5
|
+
* plugin either starts a bundled full Bun engine framework or installs the
|
|
6
|
+
* `__ELIZA_BRIDGE__` host functions for the compatibility JSContext path.
|
|
7
|
+
* The full-engine ABI lives in packages/native/bun-runtime/BRIDGE_CONTRACT.md.
|
|
8
|
+
*
|
|
9
|
+
* The plugin exposes a tiny surface to the React UI: start the runtime,
|
|
10
|
+
* send messages, check status, and stop it. Everything else flows over the
|
|
11
|
+
* `ui_post_message` / `ui_register_handler` channel inside the native side.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface StartOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Runtime engine selection:
|
|
17
|
+
* - "auto" (default): use a bundled full Bun engine when present. The
|
|
18
|
+
* JSContext compatibility fallback is for development/sideload builds only;
|
|
19
|
+
* iOS store local mode must request "bun" and fail if the engine is missing.
|
|
20
|
+
* - "bun": require ElizaBunEngine.framework and fail if it is missing.
|
|
21
|
+
* - "compat": force the JSContext compatibility bridge for development.
|
|
22
|
+
*/
|
|
23
|
+
engine?: "auto" | "bun" | "compat";
|
|
24
|
+
/**
|
|
25
|
+
* Path to the agent bundle JavaScript file. When omitted, the runtime
|
|
26
|
+
* loads the staged iOS agent payload from `public/agent/agent-bundle.js`
|
|
27
|
+
* in the main app bundle resources. Legacy JSContext development bundles
|
|
28
|
+
* named `agent-bundle-ios.js` are still probed for compatibility.
|
|
29
|
+
* Use this only for development overrides.
|
|
30
|
+
*/
|
|
31
|
+
bundlePath?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional polyfill prefix loaded before the agent bundle. When omitted,
|
|
34
|
+
* the runtime loads `eliza-polyfill-prefix.js` from the main app bundle
|
|
35
|
+
* resources, or falls back to a minimal embedded prefix.
|
|
36
|
+
*/
|
|
37
|
+
polyfillPath?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Initial environment variables visible to the agent via `env_get` / `env_keys`.
|
|
40
|
+
*/
|
|
41
|
+
env?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* argv vector exposed to the agent via `argv()`. Defaults to
|
|
44
|
+
* `["bun", "public/agent/agent-bundle.js"]`.
|
|
45
|
+
*/
|
|
46
|
+
argv?: string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface StartResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
error?: string;
|
|
52
|
+
/** Version string emitted by `__ELIZA_BRIDGE_VERSION__`. */
|
|
53
|
+
bridgeVersion?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface SendMessageOptions {
|
|
57
|
+
message: string;
|
|
58
|
+
/** Optional conversation/thread identifier passed through to the agent. */
|
|
59
|
+
conversationId?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface SendMessageResult {
|
|
63
|
+
reply: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface GetStatusResult {
|
|
67
|
+
ready: boolean;
|
|
68
|
+
/** Active runtime engine: full Bun framework or compatibility bridge. */
|
|
69
|
+
engine?: "bun" | "compat";
|
|
70
|
+
/** Currently loaded llama model path, if any. */
|
|
71
|
+
model?: string;
|
|
72
|
+
/** Last observed generation throughput. */
|
|
73
|
+
tokensPerSecond?: number;
|
|
74
|
+
/** Bridge version string, e.g. "v1". */
|
|
75
|
+
bridgeVersion?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Generic call surface for any UI handler the agent has registered via
|
|
80
|
+
* `bridge.ui_register_handler`. The React UI passes a method name and args;
|
|
81
|
+
* the native plugin dispatches into the JSContext and returns the result.
|
|
82
|
+
*/
|
|
83
|
+
export interface CallOptions {
|
|
84
|
+
method: string;
|
|
85
|
+
args?: unknown;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface CallResult {
|
|
89
|
+
result: unknown;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface LocalTtsStatusResult {
|
|
93
|
+
ready: boolean;
|
|
94
|
+
status: "assets-ready" | "engine-ready" | "ready" | "missing" | "unavailable";
|
|
95
|
+
message: string;
|
|
96
|
+
modelId?: string;
|
|
97
|
+
bundleDir?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface LocalTtsDiagnosticsOptions {
|
|
101
|
+
bundleDir?: string;
|
|
102
|
+
probe?: boolean;
|
|
103
|
+
text?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface LocalTtsDiagnosticsResult {
|
|
107
|
+
available: boolean;
|
|
108
|
+
selectedBundleDir?: string;
|
|
109
|
+
modelId?: string;
|
|
110
|
+
message?: string;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface SynthesizeLocalTtsOptions {
|
|
115
|
+
text: string;
|
|
116
|
+
bundleDir?: string;
|
|
117
|
+
speakerPresetId?: string;
|
|
118
|
+
voice?: string;
|
|
119
|
+
voiceId?: string;
|
|
120
|
+
maxSamples?: number;
|
|
121
|
+
play?: boolean;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SynthesizeLocalTtsResult {
|
|
125
|
+
audioBase64?: string;
|
|
126
|
+
contentType: "audio/wav";
|
|
127
|
+
sampleRate: number;
|
|
128
|
+
samples: number;
|
|
129
|
+
durationMs: number;
|
|
130
|
+
modelId?: string;
|
|
131
|
+
played?: boolean;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ElizaBunRuntimePlugin {
|
|
135
|
+
start(options: StartOptions): Promise<StartResult>;
|
|
136
|
+
sendMessage(options: SendMessageOptions): Promise<SendMessageResult>;
|
|
137
|
+
getStatus(): Promise<GetStatusResult>;
|
|
138
|
+
stop(): Promise<void>;
|
|
139
|
+
getLocalTtsStatus(): Promise<LocalTtsStatusResult>;
|
|
140
|
+
getLocalTtsDiagnostics(
|
|
141
|
+
options?: LocalTtsDiagnosticsOptions,
|
|
142
|
+
): Promise<LocalTtsDiagnosticsResult>;
|
|
143
|
+
synthesizeLocalTts(
|
|
144
|
+
options: SynthesizeLocalTtsOptions,
|
|
145
|
+
): Promise<SynthesizeLocalTtsResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Invoke an arbitrary UI handler that the agent has registered via
|
|
148
|
+
* `bridge.ui_register_handler`. Useful for routing arbitrary RPC-style
|
|
149
|
+
* traffic from the React UI into the agent.
|
|
150
|
+
*/
|
|
151
|
+
call(options: CallOptions): Promise<CallResult>;
|
|
152
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ElizaBunRuntimePlugin } from "./definitions";
|
|
2
|
+
export * from "./definitions";
|
|
3
|
+
/**
|
|
4
|
+
* The native plugin is registered under the JS name `ElizaBunRuntime`. The
|
|
5
|
+
* Swift class in `ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntimePlugin.swift`
|
|
6
|
+
* exposes the matching `jsName`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ElizaBunRuntime: ElizaBunRuntimePlugin;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,cAAc,eAAe,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,eAAe,uBAK3B,CAAC"}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { registerPlugin } from "@capacitor/core";
|
|
2
|
+
import type { ElizaBunRuntimePlugin } from "./definitions";
|
|
3
|
+
|
|
4
|
+
export * from "./definitions";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The native plugin is registered under the JS name `ElizaBunRuntime`. The
|
|
8
|
+
* Swift class in `ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntimePlugin.swift`
|
|
9
|
+
* exposes the matching `jsName`.
|
|
10
|
+
*/
|
|
11
|
+
export const ElizaBunRuntime = registerPlugin<ElizaBunRuntimePlugin>(
|
|
12
|
+
"ElizaBunRuntime",
|
|
13
|
+
{
|
|
14
|
+
web: () => import("./web").then((m) => new m.ElizaBunRuntimeWeb()),
|
|
15
|
+
},
|
|
16
|
+
);
|
package/src/web.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
import type { CallOptions, CallResult, ElizaBunRuntimePlugin, GetStatusResult, LocalTtsDiagnosticsOptions, LocalTtsDiagnosticsResult, LocalTtsStatusResult, SendMessageOptions, SendMessageResult, SynthesizeLocalTtsOptions, SynthesizeLocalTtsResult, StartOptions, StartResult } from "./definitions";
|
|
3
|
+
/**
|
|
4
|
+
* Web fallback for `@elizaos/capacitor-bun-runtime`.
|
|
5
|
+
*
|
|
6
|
+
* Browser environments do not host the native runtime. This implementation
|
|
7
|
+
* reports an unavailable status and throws clear errors for runtime calls.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ElizaBunRuntimeWeb extends WebPlugin implements ElizaBunRuntimePlugin {
|
|
10
|
+
start(_options: StartOptions): Promise<StartResult>;
|
|
11
|
+
sendMessage(_options: SendMessageOptions): Promise<SendMessageResult>;
|
|
12
|
+
getStatus(): Promise<GetStatusResult>;
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
getLocalTtsStatus(): Promise<LocalTtsStatusResult>;
|
|
15
|
+
getLocalTtsDiagnostics(_options?: LocalTtsDiagnosticsOptions): Promise<LocalTtsDiagnosticsResult>;
|
|
16
|
+
synthesizeLocalTts(_options: SynthesizeLocalTtsOptions): Promise<SynthesizeLocalTtsResult>;
|
|
17
|
+
call(_options: CallOptions): Promise<CallResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=web.d.ts.map
|
package/src/web.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,qBAAa,kBACX,SAAQ,SACR,YAAW,qBAAqB;IAE1B,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAQnD,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAMrE,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC;IAIrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,iBAAiB,IAAI,OAAO,CAAC,oBAAoB,CAAC;IASlD,sBAAsB,CAC1B,QAAQ,CAAC,EAAE,0BAA0B,GACpC,OAAO,CAAC,yBAAyB,CAAC;IAQ/B,kBAAkB,CACtB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,wBAAwB,CAAC;IAM9B,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAGvD"}
|
package/src/web.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { WebPlugin } from "@capacitor/core";
|
|
2
|
+
import type {
|
|
3
|
+
CallOptions,
|
|
4
|
+
CallResult,
|
|
5
|
+
ElizaBunRuntimePlugin,
|
|
6
|
+
GetStatusResult,
|
|
7
|
+
LocalTtsDiagnosticsOptions,
|
|
8
|
+
LocalTtsDiagnosticsResult,
|
|
9
|
+
LocalTtsStatusResult,
|
|
10
|
+
SendMessageOptions,
|
|
11
|
+
SendMessageResult,
|
|
12
|
+
SynthesizeLocalTtsOptions,
|
|
13
|
+
SynthesizeLocalTtsResult,
|
|
14
|
+
StartOptions,
|
|
15
|
+
StartResult,
|
|
16
|
+
} from "./definitions";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Web fallback for `@elizaos/capacitor-bun-runtime`.
|
|
20
|
+
*
|
|
21
|
+
* Browser environments do not host the native runtime. This implementation
|
|
22
|
+
* reports an unavailable status and throws clear errors for runtime calls.
|
|
23
|
+
*/
|
|
24
|
+
export class ElizaBunRuntimeWeb
|
|
25
|
+
extends WebPlugin
|
|
26
|
+
implements ElizaBunRuntimePlugin
|
|
27
|
+
{
|
|
28
|
+
async start(_options: StartOptions): Promise<StartResult> {
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error:
|
|
32
|
+
"ElizaBunRuntime is not available on web. Run on an iOS device or simulator.",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async sendMessage(_options: SendMessageOptions): Promise<SendMessageResult> {
|
|
37
|
+
throw this.unavailable(
|
|
38
|
+
"ElizaBunRuntime.sendMessage is unavailable on web.",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async getStatus(): Promise<GetStatusResult> {
|
|
43
|
+
return { ready: false };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async stop(): Promise<void> {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async getLocalTtsStatus(): Promise<LocalTtsStatusResult> {
|
|
51
|
+
return {
|
|
52
|
+
ready: false,
|
|
53
|
+
status: "unavailable",
|
|
54
|
+
message:
|
|
55
|
+
"ElizaBunRuntime local TTS is not available on web. Run on an iOS device or simulator.",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getLocalTtsDiagnostics(
|
|
60
|
+
_options?: LocalTtsDiagnosticsOptions,
|
|
61
|
+
): Promise<LocalTtsDiagnosticsResult> {
|
|
62
|
+
return {
|
|
63
|
+
available: false,
|
|
64
|
+
message:
|
|
65
|
+
"ElizaBunRuntime local TTS diagnostics are not available on web. Run on an iOS device or simulator.",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async synthesizeLocalTts(
|
|
70
|
+
_options: SynthesizeLocalTtsOptions,
|
|
71
|
+
): Promise<SynthesizeLocalTtsResult> {
|
|
72
|
+
throw this.unavailable(
|
|
73
|
+
"ElizaBunRuntime.synthesizeLocalTts is unavailable on web.",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async call(_options: CallOptions): Promise<CallResult> {
|
|
78
|
+
throw this.unavailable("ElizaBunRuntime.call is unavailable on web.");
|
|
79
|
+
}
|
|
80
|
+
}
|