@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.
Files changed (61) hide show
  1. package/ElizaosCapacitorBunRuntime.podspec +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -0
  4. package/dist/esm/definitions.d.ts +136 -0
  5. package/dist/esm/definitions.d.ts.map +1 -0
  6. package/dist/esm/definitions.js +14 -0
  7. package/dist/esm/definitions.js.map +1 -0
  8. package/dist/esm/index.d.ts +9 -0
  9. package/dist/esm/index.d.ts.map +1 -0
  10. package/dist/esm/index.js +11 -0
  11. package/dist/esm/index.js.map +1 -0
  12. package/dist/esm/web.d.ts +19 -0
  13. package/dist/esm/web.d.ts.map +1 -0
  14. package/dist/esm/web.js +44 -0
  15. package/dist/esm/web.js.map +1 -0
  16. package/dist/plugin.cjs.js +63 -0
  17. package/dist/plugin.cjs.js.map +1 -0
  18. package/dist/plugin.js +66 -0
  19. package/dist/plugin.js.map +1 -0
  20. package/ios/Sources/ElizaBunRuntimePlugin/BridgeInstaller.swift +94 -0
  21. package/ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntime.swift +705 -0
  22. package/ios/Sources/ElizaBunRuntimePlugin/ElizaBunRuntimePlugin.swift +1109 -0
  23. package/ios/Sources/ElizaBunRuntimePlugin/FullBunEngineHost.swift +677 -0
  24. package/ios/Sources/ElizaBunRuntimePlugin/JSContextHelpers.swift +226 -0
  25. package/ios/Sources/ElizaBunRuntimePlugin/SandboxPaths.swift +46 -0
  26. package/ios/Sources/ElizaBunRuntimePlugin/bridge/CryptoBridge.swift +238 -0
  27. package/ios/Sources/ElizaBunRuntimePlugin/bridge/ElizaSqliteVecBridge.m +28 -0
  28. package/ios/Sources/ElizaBunRuntimePlugin/bridge/FSBridge.swift +270 -0
  29. package/ios/Sources/ElizaBunRuntimePlugin/bridge/HTTPBridge.swift +153 -0
  30. package/ios/Sources/ElizaBunRuntimePlugin/bridge/HTTPServerBridge.swift +32 -0
  31. package/ios/Sources/ElizaBunRuntimePlugin/bridge/LlamaBridge.swift +233 -0
  32. package/ios/Sources/ElizaBunRuntimePlugin/bridge/LlamaBridgeImpl.swift +1863 -0
  33. package/ios/Sources/ElizaBunRuntimePlugin/bridge/LogBridge.swift +36 -0
  34. package/ios/Sources/ElizaBunRuntimePlugin/bridge/PathsBridge.swift +41 -0
  35. package/ios/Sources/ElizaBunRuntimePlugin/bridge/ProcessBridge.swift +80 -0
  36. package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteBridge.swift +406 -0
  37. package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteBridgeInstaller.swift +17 -0
  38. package/ios/Sources/ElizaBunRuntimePlugin/bridge/SqliteVecLoader.swift +66 -0
  39. package/ios/Sources/ElizaBunRuntimePlugin/bridge/UIBridge.swift +72 -0
  40. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlChinesePhonemizer.swift +313 -0
  41. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlConfiguration.swift +28 -0
  42. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlEngine.swift +325 -0
  43. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlHindiPhonemizer.swift +150 -0
  44. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlJapanesePhonemizer.swift +209 -0
  45. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlLatinPhonemizer.swift +374 -0
  46. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlModel.swift +87 -0
  47. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlPhonemizer.swift +679 -0
  48. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlPronunciationDicts.swift +131 -0
  49. package/ios/Sources/ElizaBunRuntimePlugin/kokoro/KokoroCoreMlSupport.swift +24 -0
  50. package/ios/Tests/llama-bridge-smoke-main.swift +92 -0
  51. package/package.json +68 -0
  52. package/src/bridge-contract.test.ts +127 -0
  53. package/src/definitions.d.ts +136 -0
  54. package/src/definitions.d.ts.map +1 -0
  55. package/src/definitions.ts +152 -0
  56. package/src/index.d.ts +9 -0
  57. package/src/index.d.ts.map +1 -0
  58. package/src/index.ts +16 -0
  59. package/src/web.d.ts +19 -0
  60. package/src/web.d.ts.map +1 -0
  61. package/src/web.ts +80 -0
@@ -0,0 +1,94 @@
1
+ import Foundation
2
+ import JavaScriptCore
3
+ import Capacitor
4
+
5
+ /// Installs every `__ELIZA_BRIDGE__` host function on the given JSContext.
6
+ ///
7
+ /// Call once at runtime startup, before evaluating the polyfill prefix or
8
+ /// the agent bundle. All host functions execute on the JSContext's queue
9
+ /// (`ai.eliza.bun.runtime`); async bridges dispatch off the queue internally
10
+ /// and hop back to fulfill JS promises.
11
+ ///
12
+ /// The returned `BridgeKit` holds references to each bridge module so the
13
+ /// caller can release runtime-owned resources when the runtime stops.
14
+ public struct BridgeKit {
15
+ public let fs: FSBridge
16
+ public let paths: PathsBridge
17
+ public let crypto: CryptoBridge
18
+ public let http: HTTPBridge
19
+ public let httpServer: HTTPServerBridge
20
+ public let llama: LlamaBridge
21
+ public let log: LogBridge
22
+ public let process: ProcessBridge
23
+ public let ui: UIBridge
24
+ }
25
+
26
+ public enum BridgeInstaller {
27
+ public static let version = "v1"
28
+
29
+ public static func install(
30
+ into ctx: JSContext,
31
+ paths: SandboxPaths,
32
+ plugin: CAPPluginRef,
33
+ argv: [String],
34
+ env: [String: String],
35
+ runtime: ElizaBunRuntime
36
+ ) -> BridgeKit {
37
+ // Seed the __ELIZA_BRIDGE__ object and version BEFORE installing
38
+ // host functions so the polyfill can detect them at module top-level.
39
+ ctx.evaluateScript("globalThis.__ELIZA_BRIDGE__ = globalThis.__ELIZA_BRIDGE__ || {};")
40
+ ctx.evaluateScript("globalThis.__ELIZA_BRIDGE_VERSION__ = \"\(version)\";")
41
+ if let bridge = ctx.objectForKeyedSubscript("__ELIZA_BRIDGE__") {
42
+ bridge.setObject(version, forKeyedSubscript: "version" as NSString)
43
+ }
44
+
45
+ let fs = FSBridge()
46
+ fs.install(into: ctx)
47
+
48
+ let pathsBridge = PathsBridge(paths: paths)
49
+ pathsBridge.install(into: ctx)
50
+
51
+ let crypto = CryptoBridge()
52
+ crypto.install(into: ctx)
53
+
54
+ let http = HTTPBridge()
55
+ http.install(into: ctx)
56
+
57
+ let httpServer = HTTPServerBridge()
58
+ httpServer.install(into: ctx)
59
+
60
+ let llama = LlamaBridge()
61
+ llama.install(into: ctx)
62
+
63
+ let log = LogBridge()
64
+ log.install(into: ctx)
65
+
66
+ let process = ProcessBridge(initialArgv: argv, initialEnv: env, owner: runtime)
67
+ process.install(into: ctx)
68
+
69
+ let ui = UIBridge(plugin: plugin.value)
70
+ ui.install(into: ctx)
71
+
72
+ return BridgeKit(
73
+ fs: fs,
74
+ paths: pathsBridge,
75
+ crypto: crypto,
76
+ http: http,
77
+ httpServer: httpServer,
78
+ llama: llama,
79
+ log: log,
80
+ process: process,
81
+ ui: ui
82
+ )
83
+ }
84
+ }
85
+
86
+ /// Lightweight weak-wrapper for the Capacitor plugin so we can pass it into
87
+ /// bridge constructors without creating a retain cycle through the plugin
88
+ /// instance.
89
+ public final class CAPPluginRef {
90
+ public weak var value: CAPPlugin?
91
+ public init(_ plugin: CAPPlugin?) {
92
+ self.value = plugin
93
+ }
94
+ }