@elizaos/app-core 2.0.0-alpha.85 → 2.0.0-beta.2
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/account-pool.d.ts +6 -0
- package/account-pool.d.ts.map +1 -0
- package/account-pool.js +5 -0
- package/api/__tests__/sandbox-test-helpers.d.ts +10 -0
- package/api/__tests__/sandbox-test-helpers.d.ts.map +1 -0
- package/api/__tests__/sandbox-test-helpers.js +15 -0
- package/api/auth/audit.d.ts +52 -0
- package/api/auth/audit.d.ts.map +1 -0
- package/api/auth/audit.js +126 -0
- package/api/auth/auth-context.d.ts +40 -0
- package/api/auth/auth-context.d.ts.map +1 -0
- package/api/auth/auth-context.js +68 -0
- package/api/auth/bootstrap-token.d.ts +50 -0
- package/api/auth/bootstrap-token.d.ts.map +1 -0
- package/api/auth/bootstrap-token.js +157 -0
- package/api/auth/index.d.ts +14 -0
- package/api/auth/index.d.ts.map +1 -0
- package/api/auth/index.js +13 -0
- package/api/auth/passwords.d.ts +65 -0
- package/api/auth/passwords.d.ts.map +1 -0
- package/api/auth/passwords.js +87 -0
- package/api/auth/sensitive-rate-limit.d.ts +56 -0
- package/api/auth/sensitive-rate-limit.d.ts.map +1 -0
- package/api/auth/sensitive-rate-limit.js +95 -0
- package/api/auth/sessions.d.ts +152 -0
- package/api/auth/sessions.d.ts.map +1 -0
- package/api/auth/sessions.js +298 -0
- package/api/auth/tokens.d.ts +3 -0
- package/api/auth/tokens.d.ts.map +1 -0
- package/api/auth/tokens.js +13 -0
- package/api/auth-bootstrap-routes.d.ts +32 -0
- package/api/auth-bootstrap-routes.d.ts.map +1 -0
- package/api/auth-bootstrap-routes.js +179 -0
- package/api/auth-pairing-compat-routes.d.ts +17 -0
- package/api/auth-pairing-compat-routes.d.ts.map +1 -0
- package/api/auth-pairing-compat-routes.js +301 -0
- package/api/auth-session-routes.d.ts +31 -0
- package/api/auth-session-routes.d.ts.map +1 -0
- package/api/auth-session-routes.js +560 -0
- package/api/auth.d.ts +153 -0
- package/api/auth.d.ts.map +1 -0
- package/api/auth.js +290 -0
- package/api/automation-node-contributors.d.ts +14 -0
- package/api/automation-node-contributors.d.ts.map +1 -0
- package/api/automation-node-contributors.js +14 -0
- package/api/automations-compat-routes.d.ts +18 -0
- package/api/automations-compat-routes.d.ts.map +1 -0
- package/api/automations-compat-routes.js +274 -0
- package/api/catalog-routes.d.ts +4 -0
- package/api/catalog-routes.d.ts.map +1 -0
- package/api/catalog-routes.js +61 -0
- package/api/compat-route-shared.d.ts +29 -0
- package/api/compat-route-shared.d.ts.map +1 -0
- package/api/compat-route-shared.js +298 -0
- package/api/credential-resolver.d.ts +31 -0
- package/api/credential-resolver.d.ts.map +1 -0
- package/api/credential-resolver.js +199 -0
- package/api/database-rows-compat-routes.d.ts +4 -0
- package/api/database-rows-compat-routes.d.ts.map +1 -0
- package/api/database-rows-compat-routes.js +100 -0
- package/api/dev-compat-routes.d.ts +11 -0
- package/api/dev-compat-routes.d.ts.map +1 -0
- package/api/dev-compat-routes.js +144 -0
- package/api/dev-console-log.d.ts +21 -0
- package/api/dev-console-log.d.ts.map +1 -0
- package/api/dev-console-log.js +65 -0
- package/api/dev-stack.d.ts +49 -0
- package/api/dev-stack.d.ts.map +1 -0
- package/api/dev-stack.js +60 -0
- package/api/local-inference-compat-routes.d.ts +16 -0
- package/api/local-inference-compat-routes.d.ts.map +1 -0
- package/api/local-inference-compat-routes.js +617 -0
- package/api/onboarding-compat-routes.d.ts +4 -0
- package/api/onboarding-compat-routes.d.ts.map +1 -0
- package/api/onboarding-compat-routes.js +207 -0
- package/api/plugins-compat-routes.d.ts +103 -0
- package/api/plugins-compat-routes.d.ts.map +1 -0
- package/api/plugins-compat-routes.js +1181 -0
- package/api/response.d.ts +4 -0
- package/api/response.d.ts.map +1 -0
- package/api/response.js +28 -0
- package/api/runtime-mode-routes.d.ts +13 -0
- package/api/runtime-mode-routes.d.ts.map +1 -0
- package/api/runtime-mode-routes.js +32 -0
- package/api/secrets-inventory-routes.d.ts +39 -0
- package/api/secrets-inventory-routes.d.ts.map +1 -0
- package/api/secrets-inventory-routes.js +487 -0
- package/api/secrets-manager-routes.d.ts +9 -0
- package/api/secrets-manager-routes.d.ts.map +1 -0
- package/api/secrets-manager-routes.js +476 -0
- package/api/sensitive-request-routes.d.ts +20 -0
- package/api/sensitive-request-routes.d.ts.map +1 -0
- package/api/sensitive-request-routes.js +489 -0
- package/api/sensitive-request-store.d.ts +39 -0
- package/api/sensitive-request-store.d.ts.map +1 -0
- package/api/sensitive-request-store.js +204 -0
- package/api/server-config-filter.d.ts +14 -0
- package/api/server-config-filter.d.ts.map +1 -0
- package/api/server-config-filter.js +77 -0
- package/api/server-cors.d.ts +30 -0
- package/api/server-cors.d.ts.map +1 -0
- package/api/server-cors.js +128 -0
- package/api/server-html.d.ts +4 -0
- package/api/server-html.d.ts.map +1 -0
- package/api/server-html.js +5 -0
- package/api/server-onboarding-compat.d.ts +31 -0
- package/api/server-onboarding-compat.d.ts.map +1 -0
- package/api/server-onboarding-compat.js +283 -0
- package/api/server-security.d.ts +11 -0
- package/api/server-security.d.ts.map +1 -0
- package/api/server-security.js +29 -0
- package/api/server-startup.d.ts +5 -0
- package/api/server-startup.d.ts.map +1 -0
- package/api/server-startup.js +74 -0
- package/api/server-wallet-trade.d.ts +10 -0
- package/api/server-wallet-trade.d.ts.map +1 -0
- package/api/server-wallet-trade.js +240 -0
- package/api/server.d.ts +32 -0
- package/api/server.d.ts.map +1 -0
- package/api/server.js +768 -0
- package/api/workbench-compat-routes.d.ts +11 -0
- package/api/workbench-compat-routes.d.ts.map +1 -0
- package/api/workbench-compat-routes.js +325 -0
- package/benchmark/cua-routes.d.ts +10 -0
- package/benchmark/cua-routes.d.ts.map +1 -0
- package/benchmark/cua-routes.js +179 -0
- package/benchmark/lifeops-bench-handler.d.ts +94 -0
- package/benchmark/lifeops-bench-handler.d.ts.map +1 -0
- package/benchmark/lifeops-bench-handler.js +280 -0
- package/benchmark/lifeops-fake-backend.d.ts +227 -0
- package/benchmark/lifeops-fake-backend.d.ts.map +1 -0
- package/benchmark/lifeops-fake-backend.js +499 -0
- package/benchmark/mock-plugin-base.d.ts +9 -0
- package/benchmark/mock-plugin-base.d.ts.map +1 -0
- package/benchmark/mock-plugin-base.js +325 -0
- package/benchmark/mock-plugin.d.ts +3 -0
- package/benchmark/mock-plugin.d.ts.map +1 -0
- package/benchmark/mock-plugin.js +504 -0
- package/benchmark/params.d.ts +2 -0
- package/benchmark/params.d.ts.map +1 -0
- package/benchmark/params.js +18 -0
- package/benchmark/plugin.d.ts +42 -0
- package/benchmark/plugin.d.ts.map +1 -0
- package/benchmark/plugin.js +422 -0
- package/benchmark/replay-capture.d.ts +73 -0
- package/benchmark/replay-capture.d.ts.map +1 -0
- package/benchmark/replay-capture.js +223 -0
- package/benchmark/server-utils.d.ts +100 -0
- package/benchmark/server-utils.d.ts.map +1 -0
- package/benchmark/server-utils.js +289 -0
- package/benchmark/server.d.ts +2 -0
- package/benchmark/server.d.ts.map +1 -0
- package/benchmark/server.js +1176 -0
- package/browser.d.ts +13 -0
- package/browser.d.ts.map +1 -0
- package/browser.js +15 -0
- package/cli/argv.d.ts +17 -0
- package/cli/argv.d.ts.map +1 -0
- package/cli/argv.js +140 -0
- package/cli/banner.d.ts +11 -0
- package/cli/banner.d.ts.map +1 -0
- package/cli/banner.js +36 -0
- package/cli/cli-name.d.ts +5 -0
- package/cli/cli-name.d.ts.map +1 -0
- package/cli/cli-name.js +21 -0
- package/cli/cli-utils.d.ts +5 -0
- package/cli/cli-utils.d.ts.map +1 -0
- package/cli/cli-utils.js +13 -0
- package/cli/command-format.d.ts +2 -0
- package/cli/command-format.d.ts.map +1 -0
- package/cli/command-format.js +20 -0
- package/cli/doctor/checks.d.ts +96 -0
- package/cli/doctor/checks.d.ts.map +1 -0
- package/cli/doctor/checks.js +483 -0
- package/cli/git-commit.d.ts +5 -0
- package/cli/git-commit.d.ts.map +1 -0
- package/cli/git-commit.js +106 -0
- package/cli/parse-duration.d.ts +5 -0
- package/cli/parse-duration.d.ts.map +1 -0
- package/cli/parse-duration.js +27 -0
- package/cli/plugins-cli.d.ts +26 -0
- package/cli/plugins-cli.d.ts.map +1 -0
- package/cli/plugins-cli.js +892 -0
- package/cli/profile-utils.d.ts +3 -0
- package/cli/profile-utils.d.ts.map +1 -0
- package/cli/profile-utils.js +21 -0
- package/cli/profile.d.ts +15 -0
- package/cli/profile.d.ts.map +1 -0
- package/cli/profile.js +93 -0
- package/cli/program/build-program.d.ts +3 -0
- package/cli/program/build-program.d.ts.map +1 -0
- package/cli/program/build-program.js +12 -0
- package/cli/program/command-registry.d.ts +3 -0
- package/cli/program/command-registry.d.ts.map +1 -0
- package/cli/program/command-registry.js +24 -0
- package/cli/program/help.d.ts +3 -0
- package/cli/program/help.d.ts.map +1 -0
- package/cli/program/help.js +57 -0
- package/cli/program/preaction.d.ts +3 -0
- package/cli/program/preaction.d.ts.map +1 -0
- package/cli/program/preaction.js +40 -0
- package/cli/program/register.auth.d.ts +51 -0
- package/cli/program/register.auth.d.ts.map +1 -0
- package/cli/program/register.auth.js +203 -0
- package/cli/program/register.benchmark.d.ts +3 -0
- package/cli/program/register.benchmark.d.ts.map +1 -0
- package/cli/program/register.benchmark.js +12 -0
- package/cli/program/register.config.d.ts +3 -0
- package/cli/program/register.config.d.ts.map +1 -0
- package/cli/program/register.config.js +150 -0
- package/cli/program/register.configure.d.ts +3 -0
- package/cli/program/register.configure.d.ts.map +1 -0
- package/cli/program/register.configure.js +18 -0
- package/cli/program/register.dashboard.d.ts +3 -0
- package/cli/program/register.dashboard.d.ts.map +1 -0
- package/cli/program/register.dashboard.js +124 -0
- package/cli/program/register.db.d.ts +3 -0
- package/cli/program/register.db.d.ts.map +1 -0
- package/cli/program/register.db.js +45 -0
- package/cli/program/register.doctor.d.ts +3 -0
- package/cli/program/register.doctor.d.ts.map +1 -0
- package/cli/program/register.doctor.js +170 -0
- package/cli/program/register.models.d.ts +3 -0
- package/cli/program/register.models.d.ts.map +1 -0
- package/cli/program/register.models.js +32 -0
- package/cli/program/register.setup.d.ts +16 -0
- package/cli/program/register.setup.d.ts.map +1 -0
- package/cli/program/register.setup.js +333 -0
- package/cli/program/register.start.d.ts +3 -0
- package/cli/program/register.start.d.ts.map +1 -0
- package/cli/program/register.start.js +95 -0
- package/cli/program/register.subclis.d.ts +4 -0
- package/cli/program/register.subclis.d.ts.map +1 -0
- package/cli/program/register.subclis.js +87 -0
- package/cli/program/register.update.d.ts +12 -0
- package/cli/program/register.update.d.ts.map +1 -0
- package/cli/program/register.update.js +173 -0
- package/cli/program.d.ts +2 -0
- package/cli/program.d.ts.map +1 -0
- package/cli/program.js +1 -0
- package/cli/run-main.d.ts +2 -0
- package/cli/run-main.d.ts.map +1 -0
- package/cli/run-main.js +71 -0
- package/cli/version.d.ts +2 -0
- package/cli/version.d.ts.map +1 -0
- package/cli/version.js +2 -0
- package/connectors/capacitor-jsc.d.ts +66 -0
- package/connectors/capacitor-jsc.d.ts.map +1 -0
- package/connectors/capacitor-jsc.js +39 -0
- package/connectors/capacitor-quickjs.d.ts +64 -0
- package/connectors/capacitor-quickjs.d.ts.map +1 -0
- package/connectors/capacitor-quickjs.js +50 -0
- package/connectors/capacitor-sqlite.d.ts +41 -0
- package/connectors/capacitor-sqlite.d.ts.map +1 -0
- package/connectors/capacitor-sqlite.js +87 -0
- package/diagnostics/integration-observability.d.ts +40 -0
- package/diagnostics/integration-observability.d.ts.map +1 -0
- package/diagnostics/integration-observability.js +68 -0
- package/entry.d.ts +10 -0
- package/entry.d.ts.map +1 -0
- package/entry.js +66 -0
- package/index.d.ts +34 -4
- package/index.d.ts.map +1 -1
- package/index.js +42 -6
- package/package.json +81 -151
- package/packaging/PUBLISHING_GUIDE.md +707 -0
- package/packaging/debian/changelog +9 -0
- package/packaging/debian/control +26 -0
- package/packaging/debian/copyright +27 -0
- package/packaging/debian/elizaos-app.service +15 -0
- package/packaging/debian/install +4 -0
- package/packaging/debian/postinst +28 -0
- package/packaging/debian/prerm +14 -0
- package/packaging/debian/rules +44 -0
- package/packaging/debian/source/format +1 -0
- package/packaging/flatpak/README.md +150 -0
- package/packaging/flatpak/ai.elizaos.App.desktop +11 -0
- package/packaging/flatpak/ai.elizaos.App.metainfo.xml +81 -0
- package/packaging/flatpak/ai.elizaos.App.store.yml +142 -0
- package/packaging/flatpak/ai.elizaos.App.yml +142 -0
- package/packaging/flatpak/elizaos-app-wrapper.sh +5 -0
- package/packaging/flatpak/elizaos-app-wrapper.store.sh +16 -0
- package/packaging/flatpak/icons/128x128/ai.elizaos.App.png +0 -0
- package/packaging/flatpak/icons/256x256/ai.elizaos.App.png +0 -0
- package/packaging/flatpak/icons/512x512/ai.elizaos.App.png +0 -0
- package/packaging/homebrew/README.md +80 -0
- package/packaging/homebrew/elizaos-app.cask.rb +60 -0
- package/packaging/homebrew/elizaos-app.rb +49 -0
- package/packaging/inno/ElizaOSApp.iss +53 -0
- package/packaging/inno/build-inno.ps1 +231 -0
- package/packaging/msix/AppxManifest.store.xml +79 -0
- package/packaging/msix/AppxManifest.xml +53 -0
- package/packaging/msix/README.md +201 -0
- package/packaging/msix/assets/LargeTile.png +0 -0
- package/packaging/msix/assets/Square150x150Logo.png +0 -0
- package/packaging/msix/assets/Square44x44Logo.png +0 -0
- package/packaging/msix/assets/StoreLogo.png +0 -0
- package/packaging/msix/assets/Wide310x150Logo.png +0 -0
- package/packaging/msix/build-msix.ps1 +206 -0
- package/packaging/msix/generate-placeholder-assets.ps1 +49 -0
- package/packaging/msix/store/description.md +31 -0
- package/packaging/msix/store/listing.json +27 -0
- package/packaging/pypi/README.md +14 -0
- package/packaging/pypi/elizaos_app/__init__.py +7 -0
- package/packaging/pypi/elizaos_app/__main__.py +6 -0
- package/packaging/pypi/elizaos_app/cli.py +21 -0
- package/packaging/pypi/elizaos_app/loader.py +127 -0
- package/packaging/pypi/elizaos_app/py.typed +1 -0
- package/packaging/pypi/pyproject.toml +38 -0
- package/packaging/snap/snapcraft.yaml +560 -0
- package/packaging/test-packaging.sh +309 -0
- package/patches/@noble%2Fcurves@2.0.1.patch +33 -0
- package/patches/@pixiv%2Fthree-vrm@3.5.2.patch +26 -0
- package/patches/coding-agent-adapters@0.16.3.patch +44 -0
- package/patches/electrobun@1.16.0.patch +13 -0
- package/patches/llama-cpp-capacitor@0.1.5.patch +2387 -0
- package/patches/proper-lockfile@4.1.2.patch +14 -0
- package/patches/pty-manager@1.11.0.patch +194 -0
- package/permissions/types.d.ts +8 -0
- package/permissions/types.d.ts.map +1 -0
- package/permissions/types.js +7 -0
- package/platform/agent-browser-stub.d.ts +27 -0
- package/platform/agent-browser-stub.d.ts.map +1 -0
- package/platform/agent-browser-stub.js +16 -0
- package/platform/empty-node-module.d.ts +31 -0
- package/platform/empty-node-module.d.ts.map +1 -0
- package/platform/empty-node-module.js +22 -0
- package/platforms/android/Gemfile +6 -0
- package/platforms/android/README.md +79 -0
- package/platforms/android/app/build.gradle +124 -0
- package/platforms/android/app/capacitor.build.gradle +32 -0
- package/platforms/android/app/proguard-rules.pro +46 -0
- package/platforms/android/app/src/androidTest/java/ai/elizaos/app/ElizaOsInstrumentedTest.java +162 -0
- package/platforms/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
- package/platforms/android/app/src/main/AndroidManifest.xml +83 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/AgentPlugin.java +232 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAgentService.java +1514 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaAssistActivity.java +21 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBootReceiver.java +61 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaBrowserActivity.java +39 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCalendarActivity.java +75 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaCameraActivity.java +54 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaClockActivity.java +70 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaContactsActivity.java +56 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaDialActivity.java +83 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaInCallService.java +168 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaMmsReceiver.java +70 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaNativeBridge.java +38 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaRespondViaMessageService.java +119 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsComposeActivity.java +50 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/ElizaSmsReceiver.java +84 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/GatewayConnectionService.java +211 -0
- package/platforms/android/app/src/main/java/ai/elizaos/app/MainActivity.java +202 -0
- package/platforms/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/platforms/android/app/src/main/res/drawable/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
- package/platforms/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
- package/platforms/android/app/src/main/res/layout/activity_main.xml +12 -0
- package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/platforms/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/platforms/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/platforms/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
- package/platforms/android/app/src/main/res/values/strings.xml +7 -0
- package/platforms/android/app/src/main/res/values/styles.xml +22 -0
- package/platforms/android/app/src/main/res/xml/file_paths.xml +5 -0
- package/platforms/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
- package/platforms/android/build.gradle +63 -0
- package/platforms/android/capacitor-cordova-android-plugins/build.gradle +53 -0
- package/platforms/android/capacitor-cordova-android-plugins/cordova.variables.gradle +3 -0
- package/platforms/android/capacitor-cordova-android-plugins/src/main/AndroidManifest.xml +3 -0
- package/platforms/android/capacitor-cordova-android-plugins/src/main/java/.gitkeep +1 -0
- package/platforms/android/capacitor-cordova-android-plugins/src/main/res/.gitkeep +1 -0
- package/platforms/android/capacitor.settings.gradle +45 -0
- package/platforms/android/fastlane/Appfile +2 -0
- package/platforms/android/fastlane/Fastfile +59 -0
- package/platforms/android/fastlane/metadata/android/en-US/full_description.txt +24 -0
- package/platforms/android/fastlane/metadata/android/en-US/short_description.txt +1 -0
- package/platforms/android/fastlane/metadata/android/en-US/title.txt +1 -0
- package/platforms/android/fastlane/metadata/android/en-US/video.txt +0 -0
- package/platforms/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/platforms/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/platforms/android/gradle.properties +27 -0
- package/platforms/android/gradlew +251 -0
- package/platforms/android/gradlew.bat +94 -0
- package/platforms/android/settings.gradle +13 -0
- package/platforms/android/variables.gradle +17 -0
- package/platforms/electrobun/.generated/brand-config.json +8 -0
- package/platforms/electrobun/README.md +44 -0
- package/platforms/electrobun/assets/appIcon.ico +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_128x128.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_128x128@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_16x16.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_16x16@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_256x256.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_256x256@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_32x32.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_32x32@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_512x512.png +0 -0
- package/platforms/electrobun/assets/appIcon.iconset/icon_512x512@2x.png +0 -0
- package/platforms/electrobun/assets/appIcon.png +0 -0
- package/platforms/electrobun/assets/brand-config.json +8 -0
- package/platforms/electrobun/biome.json +11 -0
- package/platforms/electrobun/electrobun.config.ts +435 -0
- package/platforms/electrobun/entitlements/README.md +54 -0
- package/platforms/electrobun/entitlements/mas-child.entitlements +10 -0
- package/platforms/electrobun/entitlements/mas.entitlements +41 -0
- package/platforms/electrobun/native/macos/window-effects.mm +1030 -0
- package/platforms/electrobun/package.json +42 -0
- package/platforms/electrobun/scripts/bin/zip +2 -0
- package/platforms/electrobun/scripts/build-macos-effects.sh +31 -0
- package/platforms/electrobun/scripts/build-whisper-universal.sh +137 -0
- package/platforms/electrobun/scripts/build-whisper.sh +95 -0
- package/platforms/electrobun/scripts/ensure-whisper-model.sh +93 -0
- package/platforms/electrobun/scripts/hdiutil-wrapper.sh +33 -0
- package/platforms/electrobun/scripts/lib/app-dir.mjs +74 -0
- package/platforms/electrobun/scripts/lib/repo-root.mjs +77 -0
- package/platforms/electrobun/scripts/local-adhoc-sign-macos.ts +214 -0
- package/platforms/electrobun/scripts/macos-direct-launcher.c +84 -0
- package/platforms/electrobun/scripts/postwrap-diagnostics.ts +423 -0
- package/platforms/electrobun/scripts/postwrap-sign-runtime-macos.ts +352 -0
- package/platforms/electrobun/scripts/sign-windows.ps1 +121 -0
- package/platforms/electrobun/scripts/smoke-test-windows.ps1 +907 -0
- package/platforms/electrobun/scripts/smoke-test.sh +1186 -0
- package/platforms/electrobun/scripts/stage-macos-release-artifacts.sh +491 -0
- package/platforms/electrobun/scripts/sync-web-assets.mjs +48 -0
- package/platforms/electrobun/scripts/verify-rpc-handlers.ts +162 -0
- package/platforms/electrobun/scripts/verify-windows-installer-proof.ps1 +203 -0
- package/platforms/electrobun/scripts/xcrun-wrapper.sh +80 -0
- package/platforms/electrobun/scripts/zip-wrapper.sh +6 -0
- package/platforms/electrobun/src/__stubs__/bun-ffi.ts +51 -0
- package/platforms/electrobun/src/__stubs__/electrobun-bun.ts +20 -0
- package/platforms/electrobun/src/agent-ready-state.ts +35 -0
- package/platforms/electrobun/src/agent-reset-from-main.ts +87 -0
- package/platforms/electrobun/src/api-base.ts +169 -0
- package/platforms/electrobun/src/application-menu-action-registry.ts +21 -0
- package/platforms/electrobun/src/application-menu.ts +418 -0
- package/platforms/electrobun/src/background-notice.ts +65 -0
- package/platforms/electrobun/src/brand-config.ts +184 -0
- package/platforms/electrobun/src/bridge/browser-tabs-renderer-registry.ts +60 -0
- package/platforms/electrobun/src/bridge/electrobun-direct-rpc.ts +430 -0
- package/platforms/electrobun/src/bridge/electrobun-preload.ts +1 -0
- package/platforms/electrobun/src/bridge/electrobun-stub.ts +21 -0
- package/platforms/electrobun/src/browser-workspace-bridge-server.ts +284 -0
- package/platforms/electrobun/src/cloud-auth-window.ts +216 -0
- package/platforms/electrobun/src/cloud-disconnect-from-main.ts +118 -0
- package/platforms/electrobun/src/constants.ts +2 -0
- package/platforms/electrobun/src/desktop-http-request.test.ts +85 -0
- package/platforms/electrobun/src/desktop-http-request.ts +103 -0
- package/platforms/electrobun/src/desktop-test-bridge-server.ts +248 -0
- package/platforms/electrobun/src/devtools-layout.ts +63 -0
- package/platforms/electrobun/src/diagnostic-format.ts +65 -0
- package/platforms/electrobun/src/fatal-shutdown.test.ts +30 -0
- package/platforms/electrobun/src/fatal-shutdown.ts +10 -0
- package/platforms/electrobun/src/floating-chat-window.ts +239 -0
- package/platforms/electrobun/src/index.ts +2510 -0
- package/platforms/electrobun/src/libMacWindowEffects.dylib +0 -0
- package/platforms/electrobun/src/lifecycle/api-base-owner.ts +119 -0
- package/platforms/electrobun/src/lifecycle/desktop-session-prime.ts +77 -0
- package/platforms/electrobun/src/logger.ts +23 -0
- package/platforms/electrobun/src/main-window-runtime.ts +117 -0
- package/platforms/electrobun/src/main-window-session.ts +88 -0
- package/platforms/electrobun/src/menu-reset-from-main.ts +211 -0
- package/platforms/electrobun/src/native/agent.ts +1963 -0
- package/platforms/electrobun/src/native/auth-bridge.ts +525 -0
- package/platforms/electrobun/src/native/browser-workspace.ts +574 -0
- package/platforms/electrobun/src/native/camera.ts +68 -0
- package/platforms/electrobun/src/native/canvas.ts +504 -0
- package/platforms/electrobun/src/native/credentials.ts +765 -0
- package/platforms/electrobun/src/native/desktop.ts +2317 -0
- package/platforms/electrobun/src/native/editor-bridge.ts +292 -0
- package/platforms/electrobun/src/native/file-watcher.ts +220 -0
- package/platforms/electrobun/src/native/gateway.ts +218 -0
- package/platforms/electrobun/src/native/gpu-window.ts +301 -0
- package/platforms/electrobun/src/native/index.ts +105 -0
- package/platforms/electrobun/src/native/location.ts +110 -0
- package/platforms/electrobun/src/native/loopback-port.ts +81 -0
- package/platforms/electrobun/src/native/mac-window-effects.ts +178 -0
- package/platforms/electrobun/src/native/music-player.ts +61 -0
- package/platforms/electrobun/src/native/permissions-shared.ts +171 -0
- package/platforms/electrobun/src/native/permissions.ts +242 -0
- package/platforms/electrobun/src/native/power-state.ts +195 -0
- package/platforms/electrobun/src/native/screencapture.ts +654 -0
- package/platforms/electrobun/src/native/steward.ts +343 -0
- package/platforms/electrobun/src/native/swabble.ts +349 -0
- package/platforms/electrobun/src/native/talkmode.ts +441 -0
- package/platforms/electrobun/src/native/webgpu-browser-support.ts +220 -0
- package/platforms/electrobun/src/native/whisper.ts +280 -0
- package/platforms/electrobun/src/preload-validation.ts +65 -0
- package/platforms/electrobun/src/preload.js +1 -0
- package/platforms/electrobun/src/print-electrobun-dev-settings-banner.ts +140 -0
- package/platforms/electrobun/src/renderer-static.ts +77 -0
- package/platforms/electrobun/src/rpc-handlers.ts +1079 -0
- package/platforms/electrobun/src/rpc-schema.ts +1870 -0
- package/platforms/electrobun/src/runtime-layout.ts +150 -0
- package/platforms/electrobun/src/runtime-permissions.ts +131 -0
- package/platforms/electrobun/src/screenshot-dev-server.ts +125 -0
- package/platforms/electrobun/src/startup-trace.ts +351 -0
- package/platforms/electrobun/src/surface-windows.ts +475 -0
- package/platforms/electrobun/src/types/web-speech.d.ts +52 -0
- package/platforms/electrobun/src/types.ts +18 -0
- package/platforms/electrobun/src/windows-cef-profile.ts +124 -0
- package/platforms/electrobun/tsconfig.json +75 -0
- package/platforms/electrobun/vitest.electrobun.config.ts +54 -0
- package/platforms/ios/App/App/App.entitlements +18 -0
- package/platforms/ios/App/App/AppDelegate.swift +93 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-marketing-1024.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-20x20@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-29x29@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-40x40@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@1x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-76x76@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-ipad-83_5x83_5@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-20x20@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-29x29@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-40x40@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@2x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-iphone-60x60@3x.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +116 -0
- package/platforms/ios/App/App/Assets.xcassets/Contents.json +6 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
- package/platforms/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
- package/platforms/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
- package/platforms/ios/App/App/Base.lproj/Main.storyboard +19 -0
- package/platforms/ios/App/App/ElizaIntentPlugin.swift +185 -0
- package/platforms/ios/App/App/Info.plist +123 -0
- package/platforms/ios/App/App/PrivacyInfo.xcprivacy +55 -0
- package/platforms/ios/App/App/SceneDelegate.swift +77 -0
- package/platforms/ios/App/App/WebsiteBlockerContentExtension/ActionRequestHandler.swift +142 -0
- package/platforms/ios/App/App/WebsiteBlockerContentExtension/Info.plist +29 -0
- package/platforms/ios/App/App/WebsiteBlockerContentExtension/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/App/App/WebsiteBlockerContentExtension/WebsiteBlockerContentExtension.entitlements +10 -0
- package/platforms/ios/App/App.xcodeproj/project.pbxproj +596 -0
- package/platforms/ios/App/App.xcworkspace/contents.xcworkspacedata +10 -0
- package/platforms/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/platforms/ios/App/ExportOptions.plist +18 -0
- package/platforms/ios/App/Podfile +51 -0
- package/platforms/ios/App/Podfile.lock +131 -0
- package/platforms/ios/Gemfile +6 -0
- package/platforms/ios/fastlane/Appfile +4 -0
- package/platforms/ios/fastlane/Fastfile +94 -0
- package/platforms/ios/fastlane/Matchfile +12 -0
- package/platforms/ios/fastlane/metadata/en-US/description.txt +22 -0
- package/platforms/ios/fastlane/metadata/en-US/keywords.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/marketing_url.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/name.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/privacy_url.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/promotional_text.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/subtitle.txt +1 -0
- package/platforms/ios/fastlane/metadata/en-US/support_url.txt +1 -0
- package/register-runtime-hooks.d.ts +2 -0
- package/register-runtime-hooks.d.ts.map +1 -0
- package/register-runtime-hooks.js +13 -0
- package/registry/generate-apps.d.ts +2 -0
- package/registry/generate-apps.d.ts.map +1 -0
- package/registry/generate-apps.js +338 -0
- package/registry/generate.d.ts +2 -0
- package/registry/generate.d.ts.map +1 -0
- package/registry/generate.js +506 -0
- package/registry/index.d.ts +6 -0
- package/registry/index.d.ts.map +1 -0
- package/registry/index.js +68 -0
- package/registry/loader.d.ts +27 -0
- package/registry/loader.d.ts.map +1 -0
- package/registry/loader.js +111 -0
- package/registry/schema.d.ts +989 -0
- package/registry/schema.d.ts.map +1 -0
- package/registry/schema.js +264 -0
- package/runtime/api-dev-settings-banner.d.ts +7 -0
- package/runtime/api-dev-settings-banner.d.ts.map +1 -0
- package/runtime/api-dev-settings-banner.js +104 -0
- package/runtime/app-route-plugin-registry.d.ts +3 -0
- package/runtime/app-route-plugin-registry.d.ts.map +1 -0
- package/runtime/app-route-plugin-registry.js +1 -0
- package/runtime/build-character-from-config.d.ts +3 -0
- package/runtime/build-character-from-config.d.ts.map +1 -0
- package/runtime/build-character-from-config.js +59 -0
- package/runtime/build-variant.d.ts +8 -0
- package/runtime/build-variant.d.ts.map +1 -0
- package/runtime/build-variant.js +7 -0
- package/runtime/channel-plugin-map.d.ts +6 -0
- package/runtime/channel-plugin-map.d.ts.map +1 -0
- package/runtime/channel-plugin-map.js +38 -0
- package/runtime/dev-server.d.ts +2 -0
- package/runtime/dev-server.d.ts.map +1 -0
- package/runtime/dev-server.js +383 -0
- package/runtime/dev-settings-figlet-heading.d.ts +22 -0
- package/runtime/dev-settings-figlet-heading.d.ts.map +1 -0
- package/runtime/dev-settings-figlet-heading.js +55 -0
- package/runtime/eliza.d.ts +21 -0
- package/runtime/eliza.d.ts.map +1 -0
- package/runtime/eliza.js +863 -0
- package/runtime/embedding-manager-support.d.ts +77 -0
- package/runtime/embedding-manager-support.d.ts.map +1 -0
- package/runtime/embedding-manager-support.js +309 -0
- package/runtime/embedding-presets.d.ts +5 -0
- package/runtime/embedding-presets.d.ts.map +1 -0
- package/runtime/embedding-presets.js +47 -0
- package/runtime/embedding-warmup-policy.d.ts +13 -0
- package/runtime/embedding-warmup-policy.d.ts.map +1 -0
- package/runtime/embedding-warmup-policy.js +33 -0
- package/runtime/ensure-local-inference-handler.d.ts +25 -0
- package/runtime/ensure-local-inference-handler.d.ts.map +1 -0
- package/runtime/ensure-local-inference-handler.js +389 -0
- package/runtime/ensure-text-to-speech-handler.d.ts +18 -0
- package/runtime/ensure-text-to-speech-handler.d.ts.map +1 -0
- package/runtime/ensure-text-to-speech-handler.js +50 -0
- package/runtime/error-handlers.d.ts +12 -0
- package/runtime/error-handlers.d.ts.map +1 -0
- package/runtime/error-handlers.js +49 -0
- package/runtime/mobile-local-inference-gate.d.ts +21 -0
- package/runtime/mobile-local-inference-gate.d.ts.map +1 -0
- package/runtime/mobile-local-inference-gate.js +24 -0
- package/runtime/mobile-safe-runtime.d.ts +123 -0
- package/runtime/mobile-safe-runtime.d.ts.map +1 -0
- package/runtime/mobile-safe-runtime.js +290 -0
- package/runtime/mode/remote-forwarder.d.ts +35 -0
- package/runtime/mode/remote-forwarder.d.ts.map +1 -0
- package/runtime/mode/remote-forwarder.js +119 -0
- package/runtime/mode/route-mode-guard.d.ts +21 -0
- package/runtime/mode/route-mode-guard.d.ts.map +1 -0
- package/runtime/mode/route-mode-guard.js +30 -0
- package/runtime/mode/route-mode-matrix.d.ts +64 -0
- package/runtime/mode/route-mode-matrix.d.ts.map +1 -0
- package/runtime/mode/route-mode-matrix.js +125 -0
- package/runtime/mode/runtime-mode.d.ts +72 -0
- package/runtime/mode/runtime-mode.d.ts.map +1 -0
- package/runtime/mode/runtime-mode.js +167 -0
- package/runtime/runtime-bootstrap-policy.d.ts +17 -0
- package/runtime/runtime-bootstrap-policy.d.ts.map +1 -0
- package/runtime/runtime-bootstrap-policy.js +37 -0
- package/runtime/sandbox-policy.d.ts +8 -0
- package/runtime/sandbox-policy.d.ts.map +1 -0
- package/runtime/sandbox-policy.js +7 -0
- package/runtime/startup-overlay.d.ts +14 -0
- package/runtime/startup-overlay.d.ts.map +1 -0
- package/runtime/startup-overlay.js +55 -0
- package/runtime/telegram-standalone-handler.d.ts +34 -0
- package/runtime/telegram-standalone-handler.d.ts.map +1 -0
- package/runtime/telegram-standalone-handler.js +195 -0
- package/runtime/telegram-standalone-policy.d.ts +2 -0
- package/runtime/telegram-standalone-policy.d.ts.map +1 -0
- package/runtime/telegram-standalone-policy.js +14 -0
- package/scripts/README.md +27 -0
- package/scripts/align-electrobun-version.mjs +37 -0
- package/scripts/aosp/README.md +66 -0
- package/scripts/aosp/avd-test.mjs +403 -0
- package/scripts/aosp/boot-validate.mjs +536 -0
- package/scripts/aosp/build-aosp.mjs +448 -0
- package/scripts/aosp/build-bootanimation.mjs +178 -0
- package/scripts/aosp/capture-screens.mjs +325 -0
- package/scripts/aosp/compile-libllama.mjs +1333 -0
- package/scripts/aosp/compile-shim.mjs +328 -0
- package/scripts/aosp/e2e-validate.mjs +225 -0
- package/scripts/aosp/lib/load-variant-config.mjs +182 -0
- package/scripts/aosp/lint-init-rc.mjs +258 -0
- package/scripts/aosp/llama-cpp-patches/README.md +49 -0
- package/scripts/aosp/llama-cpp-patches/apply-patches.mjs +198 -0
- package/scripts/aosp/llama-cpp-patches/polarquant/0001-Q4_POLAR-register-GGML_TYPE_Q4_POLAR-45-and-block_q4.patch +108 -0
- package/scripts/aosp/llama-cpp-patches/polarquant/0002-Q4_POLAR-vendor-PolarQuant-ref-kernels-into-ggml-bas.patch +460 -0
- package/scripts/aosp/llama-cpp-patches/polarquant/0003-tests-cover-Q4_POLAR-fix-latent-buffer-overflow.patch +102 -0
- package/scripts/aosp/llama-cpp-patches/polarquant/0004-Q4_POLAR-gate-QJL-residual-on-runtime-flag-default-o.patch +97 -0
- package/scripts/aosp/llama-cpp-patches/qjl/0001-ggml-add-GGML_TYPE_QJL1_256-GGML_OP_ATTN_SCORE_QJL-e.patch +120 -0
- package/scripts/aosp/llama-cpp-patches/qjl/0002-ggml-register-QJL1_256-type-traits-ATTN_SCORE_QJL-op.patch +1392 -0
- package/scripts/aosp/llama-cpp-patches/qjl/0003-ggml-set-QJL1_256-blck_size-to-head_dim-128-not-sket.patch +56 -0
- package/scripts/aosp/llama-cpp-patches/qjl/0004-tests-add-test-qjl-cache-verifying-type-traits-score.patch +335 -0
- package/scripts/aosp/llama-cpp-patches/qjl/0005-ggml-flip-block_qjl1_256-to-signs-then-norm.patch +69 -0
- package/scripts/aosp/llama-shim/eliza_llama_shim.c +276 -0
- package/scripts/aosp/seccomp-shim/loader-wrap.c +141 -0
- package/scripts/aosp/seccomp-shim/sigsys-handler.c +338 -0
- package/scripts/aosp/sim.mjs +277 -0
- package/scripts/aosp/smoke-cuttlefish.mjs +673 -0
- package/scripts/aosp/stage-default-models.mjs +340 -0
- package/scripts/aosp/stage-models-dfm.mjs +384 -0
- package/scripts/aosp/sync-to-aosp.mjs +134 -0
- package/scripts/aosp/validate.mjs +1273 -0
- package/scripts/aosp/variant-config-schema.ts +10 -0
- package/scripts/audit-live-test-surface.mjs +590 -0
- package/scripts/audit-server-test-surface.mjs +163 -0
- package/scripts/benchmark-preflight.mjs +170 -0
- package/scripts/bin/.gitkeep +0 -0
- package/scripts/build-bundled-agent-skills-artifact.mjs +58 -0
- package/scripts/build-bundled-orchestrator-artifact.mjs +66 -0
- package/scripts/build-capacitor-app.mjs +122 -0
- package/scripts/build-electrobun-preload.mjs +117 -0
- package/scripts/build-flatpak.mjs +125 -0
- package/scripts/build-image.sh +461 -0
- package/scripts/build-llama-cpp-dflash.mjs +1866 -0
- package/scripts/build-native-plugins.mjs +153 -0
- package/scripts/build-patched-electrobun-cli.mjs +424 -0
- package/scripts/build-win.mjs +82 -0
- package/scripts/bump-elizaos.sh +438 -0
- package/scripts/check-i18n.mjs +328 -0
- package/scripts/check-secret-hygiene.mjs +344 -0
- package/scripts/check-upstream-drift.mjs +102 -0
- package/scripts/clean-repo.mjs +187 -0
- package/scripts/codesign-mas.mjs +297 -0
- package/scripts/container-entrypoint.mjs +101 -0
- package/scripts/coordinator-cross-platform-review.mjs +192 -0
- package/scripts/copy-package-assets.mjs +31 -0
- package/scripts/copy-runtime-node-modules.ts +1782 -0
- package/scripts/coverage-policy.d.mts +16 -0
- package/scripts/coverage-policy.mjs +38 -0
- package/scripts/css-coverage.mjs +241 -0
- package/scripts/deploy-image.sh +318 -0
- package/scripts/desktop-build.mjs +867 -0
- package/scripts/desktop-stack-status.mjs +80 -0
- package/scripts/dev-platform.mjs +975 -0
- package/scripts/dev-ui.mjs +1178 -0
- package/scripts/dev-win.mjs +25 -0
- package/scripts/disable-local-eliza-workspace.mjs +420 -0
- package/scripts/docker-ci-smoke.sh +500 -0
- package/scripts/docker-entrypoint.sh +11 -0
- package/scripts/docker-runtime-review.mjs +230 -0
- package/scripts/docs-list.js +206 -0
- package/scripts/ensure-avatars.mjs +335 -0
- package/scripts/ensure-bundled-workspaces.mjs +143 -0
- package/scripts/ensure-capacitor-platform.mjs +58 -0
- package/scripts/ensure-electrobun-core.mjs +318 -0
- package/scripts/ensure-generated-core-proto-js.mjs +125 -0
- package/scripts/ensure-shared-i18n-data.mjs +67 -0
- package/scripts/ensure-skills.mjs +177 -0
- package/scripts/ensure-type-package-aliases.mjs +246 -0
- package/scripts/ensure-vision-deps.mjs +196 -0
- package/scripts/entry.ts +11 -0
- package/scripts/find-collisions.mjs +765 -0
- package/scripts/find-duplicate-components.mjs +203 -0
- package/scripts/fix-workspace-deps.mjs +328 -0
- package/scripts/generate-onboarding-voicelines.mjs +194 -0
- package/scripts/generate-plugin-index.js +1055 -0
- package/scripts/generate-static-asset-manifest.mjs +15 -0
- package/scripts/generated/static-asset-manifest.json +4 -0
- package/scripts/i18n-dynamic-keys.json +128 -0
- package/scripts/init-submodules.mjs +425 -0
- package/scripts/ios-xcframework/README.md +233 -0
- package/scripts/ios-xcframework/build-xcframework.mjs +487 -0
- package/scripts/kernel-patches/metal-kernels.mjs +656 -0
- package/scripts/kernel-patches/vulkan-dispatch-patches/01-vulkan-shaders-gen.patch +41 -0
- package/scripts/kernel-patches/vulkan-dispatch-patches/02-ggml-vulkan-pipelines.patch +86 -0
- package/scripts/kernel-patches/vulkan-kernels.mjs +281 -0
- package/scripts/lib/allocate-loopback-port.mjs +58 -0
- package/scripts/lib/api-supervisor.mjs +115 -0
- package/scripts/lib/app-dir.mjs +74 -0
- package/scripts/lib/asset-cdn.mjs +118 -0
- package/scripts/lib/bun-version-guard.mjs +44 -0
- package/scripts/lib/capacitor-platform-templates.mjs +306 -0
- package/scripts/lib/capacitor-plugin-build-needed.mjs +79 -0
- package/scripts/lib/capacitor-plugin-names.mjs +35 -0
- package/scripts/lib/desktop-preflight.mjs +122 -0
- package/scripts/lib/desktop-stack-status.mjs +151 -0
- package/scripts/lib/dev-ui-onchain.mjs +22 -0
- package/scripts/lib/dev-ui-vision.mjs +15 -0
- package/scripts/lib/kill-process-tree.mjs +87 -0
- package/scripts/lib/kill-ui-listen-port.mjs +74 -0
- package/scripts/lib/node-path-env.mjs +11 -0
- package/scripts/lib/orchestrator-desktop-dev-banner.mjs +285 -0
- package/scripts/lib/patch-bun-exports.mjs +1446 -0
- package/scripts/lib/read-app-identity.mjs +54 -0
- package/scripts/lib/release-check-pack-dry-run.ts +34 -0
- package/scripts/lib/repo-root.mjs +77 -0
- package/scripts/lib/stage-android-agent.mjs +704 -0
- package/scripts/lib/static-asset-manifest.mjs +151 -0
- package/scripts/lib/sync-eliza-env-aliases.mjs +37 -0
- package/scripts/lib/vite-renderer-dist-stale.mjs +141 -0
- package/scripts/lib/workspace-discovery.mjs +108 -0
- package/scripts/lifeops-prompt-benchmark.ts +206 -0
- package/scripts/link-browser-server.mjs +157 -0
- package/scripts/link-docker-local-app-packages.mjs +345 -0
- package/scripts/link-external-plugins.mjs +195 -0
- package/scripts/mobile-auth-simulator-smoke.mjs +373 -0
- package/scripts/normalize-parallax-capture.ts +97 -0
- package/scripts/omnivoice-fuse/Makefile +44 -0
- package/scripts/omnivoice-fuse/README.md +266 -0
- package/scripts/omnivoice-fuse/cmake-graft.mjs +180 -0
- package/scripts/omnivoice-fuse/ffi-stub.c +222 -0
- package/scripts/omnivoice-fuse/ffi.h +158 -0
- package/scripts/omnivoice-fuse/libelizainference_stub.dylib +0 -0
- package/scripts/omnivoice-fuse/prepare.mjs +263 -0
- package/scripts/omnivoice-fuse/verify-symbols.mjs +138 -0
- package/scripts/pack-upstreams.mjs +392 -0
- package/scripts/patch-deps.mjs +597 -0
- package/scripts/patch-workspace-plugins.mjs +148 -0
- package/scripts/playwright-ui-live-stack.ts +667 -0
- package/scripts/playwright-ui-smoke-api-stub.mjs +1838 -0
- package/scripts/plugin-index-local-additions.json +12 -0
- package/scripts/plugin-metadata-overrides.json +165 -0
- package/scripts/pre-review-local.mjs +599 -0
- package/scripts/prepare-ios-cocoapods.sh +30 -0
- package/scripts/prepare-package-dist.mjs +358 -0
- package/scripts/process-vrms.mjs +203 -0
- package/scripts/prune-cdn-local-assets.mjs +44 -0
- package/scripts/publish-local-plugins-next.mjs +122 -0
- package/scripts/release-check.ts +1402 -0
- package/scripts/relink-workspace-packages-to-dist.mjs +115 -0
- package/scripts/replace-workspace-versions.mjs +128 -0
- package/scripts/report-coverage-surfaces.mjs +121 -0
- package/scripts/restore-workspace-refs.mjs +128 -0
- package/scripts/rt.mjs +29 -0
- package/scripts/rt.sh +4 -0
- package/scripts/run-biome-check.mjs +191 -0
- package/scripts/run-coding-agent-e2e.mjs +46 -0
- package/scripts/run-desktop-playwright.mjs +35 -0
- package/scripts/run-local-plugin-live-smoke.mjs +185 -0
- package/scripts/run-mobile-build.mjs +3308 -0
- package/scripts/run-node-runtime.mjs +75 -0
- package/scripts/run-node-tsx.mjs +62 -0
- package/scripts/run-node.mjs +294 -0
- package/scripts/run-playwright.mjs +66 -0
- package/scripts/run-production-build.mjs +138 -0
- package/scripts/run-release-contract-suite.mjs +57 -0
- package/scripts/run-repo-setup.mjs +230 -0
- package/scripts/run-screenshotter.mjs +140 -0
- package/scripts/run-ui-smoke-playwright-suite.mjs +96 -0
- package/scripts/run-windows-smoke-launcher.ps1 +35 -0
- package/scripts/run-with-env.mjs +60 -0
- package/scripts/runtime-package-manifest.ts +107 -0
- package/scripts/sandbox-setup.sh +7 -0
- package/scripts/sanitize-npm-package-metadata.mjs +165 -0
- package/scripts/set-package-version.mjs +13 -0
- package/scripts/setup-upstreams.mjs +838 -0
- package/scripts/smoke-api-status.mjs +113 -0
- package/scripts/smoke-lifeops.mjs +305 -0
- package/scripts/startup-integration-script-drift.test.ts +94 -0
- package/scripts/sync-desktop-renderer.mjs +308 -0
- package/scripts/sync-dod-gap-issues-lib.mjs +214 -0
- package/scripts/sync-dod-gap-issues.mjs +218 -0
- package/scripts/type-audit.mjs +606 -0
- package/scripts/validate-cdn-assets.mjs +307 -0
- package/scripts/validate-regression-matrix.mjs +360 -0
- package/scripts/workspace-plugin-patches/plugin-anthropic-elizaos-core-api-compat.patch +34 -0
- package/scripts/workspace-prepare.mjs +192 -0
- package/scripts/worktree-env.sh +41 -0
- package/scripts/write-build-info.ts +69 -0
- package/scripts/write-homepage-release-data.mjs +393 -0
- package/security/agent-vault-id.d.ts +16 -0
- package/security/agent-vault-id.d.ts.map +1 -0
- package/security/agent-vault-id.js +32 -0
- package/security/cloud-secret-store.d.ts +34 -0
- package/security/cloud-secret-store.d.ts.map +1 -0
- package/security/cloud-secret-store.js +65 -0
- package/security/export-guard.d.ts +34 -0
- package/security/export-guard.d.ts.map +1 -0
- package/security/export-guard.js +127 -0
- package/security/hydrate-wallet-keys-from-platform-store.d.ts +13 -0
- package/security/hydrate-wallet-keys-from-platform-store.d.ts.map +1 -0
- package/security/hydrate-wallet-keys-from-platform-store.js +116 -0
- package/security/platform-secure-store-node.d.ts +13 -0
- package/security/platform-secure-store-node.d.ts.map +1 -0
- package/security/platform-secure-store-node.js +311 -0
- package/security/platform-secure-store.d.ts +47 -0
- package/security/platform-secure-store.d.ts.map +1 -0
- package/security/platform-secure-store.js +10 -0
- package/security/wallet-os-store-actions.d.ts +45 -0
- package/security/wallet-os-store-actions.d.ts.map +1 -0
- package/security/wallet-os-store-actions.js +125 -0
- package/services/account-pool.d.ts +134 -0
- package/services/account-pool.d.ts.map +1 -0
- package/services/account-pool.js +693 -0
- package/services/account-usage.d.ts +75 -0
- package/services/account-usage.d.ts.map +1 -0
- package/services/account-usage.js +179 -0
- package/services/auth-store.d.ts +179 -0
- package/services/auth-store.d.ts.map +1 -0
- package/services/auth-store.js +404 -0
- package/services/cloud-jwks-store.d.ts +62 -0
- package/services/cloud-jwks-store.d.ts.map +1 -0
- package/services/cloud-jwks-store.js +118 -0
- package/services/connector-target-catalog.d.ts +78 -0
- package/services/connector-target-catalog.d.ts.map +1 -0
- package/services/connector-target-catalog.js +64 -0
- package/services/discord-target-source.d.ts +53 -0
- package/services/discord-target-source.d.ts.map +1 -0
- package/services/discord-target-source.js +116 -0
- package/services/github-credentials.d.ts +95 -0
- package/services/github-credentials.d.ts.map +1 -0
- package/services/github-credentials.js +144 -0
- package/services/local-inference/__stress__/cache-stress-helpers.d.ts +76 -0
- package/services/local-inference/__stress__/cache-stress-helpers.d.ts.map +1 -0
- package/services/local-inference/__stress__/cache-stress-helpers.js +238 -0
- package/services/local-inference/active-model.d.ts +180 -0
- package/services/local-inference/active-model.d.ts.map +1 -0
- package/services/local-inference/active-model.js +362 -0
- package/services/local-inference/assignments.d.ts +58 -0
- package/services/local-inference/assignments.d.ts.map +1 -0
- package/services/local-inference/assignments.js +179 -0
- package/services/local-inference/backend.d.ts +200 -0
- package/services/local-inference/backend.d.ts.map +1 -0
- package/services/local-inference/backend.js +242 -0
- package/services/local-inference/bundled-models.d.ts +34 -0
- package/services/local-inference/bundled-models.d.ts.map +1 -0
- package/services/local-inference/bundled-models.js +104 -0
- package/services/local-inference/cache-bridge.d.ts +184 -0
- package/services/local-inference/cache-bridge.d.ts.map +1 -0
- package/services/local-inference/cache-bridge.js +333 -0
- package/services/local-inference/catalog.d.ts +57 -0
- package/services/local-inference/catalog.d.ts.map +1 -0
- package/services/local-inference/catalog.js +262 -0
- package/services/local-inference/conversation-registry.d.ts +122 -0
- package/services/local-inference/conversation-registry.d.ts.map +1 -0
- package/services/local-inference/conversation-registry.js +182 -0
- package/services/local-inference/device-bridge.d.ts +139 -0
- package/services/local-inference/device-bridge.d.ts.map +1 -0
- package/services/local-inference/device-bridge.js +774 -0
- package/services/local-inference/dflash-doctor.d.ts +27 -0
- package/services/local-inference/dflash-doctor.d.ts.map +1 -0
- package/services/local-inference/dflash-doctor.js +149 -0
- package/services/local-inference/dflash-server.d.ts +248 -0
- package/services/local-inference/dflash-server.d.ts.map +1 -0
- package/services/local-inference/dflash-server.js +1076 -0
- package/services/local-inference/downloader.d.ts +48 -0
- package/services/local-inference/downloader.d.ts.map +1 -0
- package/services/local-inference/downloader.js +688 -0
- package/services/local-inference/engine.d.ts +282 -0
- package/services/local-inference/engine.d.ts.map +1 -0
- package/services/local-inference/engine.js +743 -0
- package/services/local-inference/external-scanner.d.ts +17 -0
- package/services/local-inference/external-scanner.d.ts.map +1 -0
- package/services/local-inference/external-scanner.js +261 -0
- package/services/local-inference/handler-registry.d.ts +72 -0
- package/services/local-inference/handler-registry.d.ts.map +1 -0
- package/services/local-inference/handler-registry.js +159 -0
- package/services/local-inference/hardware.d.ts +26 -0
- package/services/local-inference/hardware.d.ts.map +1 -0
- package/services/local-inference/hardware.js +139 -0
- package/services/local-inference/hf-search.d.ts +19 -0
- package/services/local-inference/hf-search.d.ts.map +1 -0
- package/services/local-inference/hf-search.js +169 -0
- package/services/local-inference/index.d.ts +10 -0
- package/services/local-inference/index.d.ts.map +1 -0
- package/services/local-inference/index.js +7 -0
- package/services/local-inference/llama-server-metrics.d.ts +108 -0
- package/services/local-inference/llama-server-metrics.d.ts.map +1 -0
- package/services/local-inference/llama-server-metrics.js +175 -0
- package/services/local-inference/manifest/index.d.ts +4 -0
- package/services/local-inference/manifest/index.d.ts.map +1 -0
- package/services/local-inference/manifest/index.js +5 -0
- package/services/local-inference/manifest/schema.d.ts +419 -0
- package/services/local-inference/manifest/schema.d.ts.map +1 -0
- package/services/local-inference/manifest/schema.js +227 -0
- package/services/local-inference/manifest/types.d.ts +23 -0
- package/services/local-inference/manifest/types.d.ts.map +1 -0
- package/services/local-inference/manifest/types.js +5 -0
- package/services/local-inference/manifest/validator.d.ts +43 -0
- package/services/local-inference/manifest/validator.d.ts.map +1 -0
- package/services/local-inference/manifest/validator.js +180 -0
- package/services/local-inference/paths.d.ts +8 -0
- package/services/local-inference/paths.d.ts.map +1 -0
- package/services/local-inference/paths.js +7 -0
- package/services/local-inference/providers.d.ts +61 -0
- package/services/local-inference/providers.d.ts.map +1 -0
- package/services/local-inference/providers.js +334 -0
- package/services/local-inference/ram-budget.d.ts +57 -0
- package/services/local-inference/ram-budget.d.ts.map +1 -0
- package/services/local-inference/ram-budget.js +107 -0
- package/services/local-inference/readiness.d.ts +9 -0
- package/services/local-inference/readiness.d.ts.map +1 -0
- package/services/local-inference/readiness.js +153 -0
- package/services/local-inference/recommendation.d.ts +62 -0
- package/services/local-inference/recommendation.d.ts.map +1 -0
- package/services/local-inference/recommendation.js +309 -0
- package/services/local-inference/registry.d.ts +35 -0
- package/services/local-inference/registry.d.ts.map +1 -0
- package/services/local-inference/registry.js +117 -0
- package/services/local-inference/router-handler.d.ts +51 -0
- package/services/local-inference/router-handler.d.ts.map +1 -0
- package/services/local-inference/router-handler.js +165 -0
- package/services/local-inference/routing-policy.d.ts +55 -0
- package/services/local-inference/routing-policy.d.ts.map +1 -0
- package/services/local-inference/routing-policy.js +195 -0
- package/services/local-inference/routing-preferences.d.ts +8 -0
- package/services/local-inference/routing-preferences.d.ts.map +1 -0
- package/services/local-inference/routing-preferences.js +7 -0
- package/services/local-inference/service.d.ts +88 -0
- package/services/local-inference/service.d.ts.map +1 -0
- package/services/local-inference/service.js +210 -0
- package/services/local-inference/session-pool.d.ts +72 -0
- package/services/local-inference/session-pool.d.ts.map +1 -0
- package/services/local-inference/session-pool.js +125 -0
- package/services/local-inference/types.d.ts +309 -0
- package/services/local-inference/types.d.ts.map +1 -0
- package/services/local-inference/types.js +23 -0
- package/services/local-inference/verify.d.ts +8 -0
- package/services/local-inference/verify.d.ts.map +1 -0
- package/services/local-inference/verify.js +7 -0
- package/services/local-inference/voice/barge-in.d.ts +15 -0
- package/services/local-inference/voice/barge-in.d.ts.map +1 -0
- package/services/local-inference/voice/barge-in.js +20 -0
- package/services/local-inference/voice/engine-bridge.d.ts +256 -0
- package/services/local-inference/voice/engine-bridge.d.ts.map +1 -0
- package/services/local-inference/voice/engine-bridge.js +398 -0
- package/services/local-inference/voice/ffi-bindings.d.ts +114 -0
- package/services/local-inference/voice/ffi-bindings.d.ts.map +1 -0
- package/services/local-inference/voice/ffi-bindings.js +281 -0
- package/services/local-inference/voice/index.d.ts +51 -0
- package/services/local-inference/voice/index.d.ts.map +1 -0
- package/services/local-inference/voice/index.js +50 -0
- package/services/local-inference/voice/lifecycle.d.ts +135 -0
- package/services/local-inference/voice/lifecycle.d.ts.map +1 -0
- package/services/local-inference/voice/lifecycle.js +189 -0
- package/services/local-inference/voice/phoneme-tokenizer.d.ts +58 -0
- package/services/local-inference/voice/phoneme-tokenizer.d.ts.map +1 -0
- package/services/local-inference/voice/phoneme-tokenizer.js +53 -0
- package/services/local-inference/voice/phrase-cache.d.ts +24 -0
- package/services/local-inference/voice/phrase-cache.d.ts.map +1 -0
- package/services/local-inference/voice/phrase-cache.js +32 -0
- package/services/local-inference/voice/phrase-chunker.d.ts +20 -0
- package/services/local-inference/voice/phrase-chunker.d.ts.map +1 -0
- package/services/local-inference/voice/phrase-chunker.js +85 -0
- package/services/local-inference/voice/ring-buffer.d.ts +40 -0
- package/services/local-inference/voice/ring-buffer.d.ts.map +1 -0
- package/services/local-inference/voice/ring-buffer.js +85 -0
- package/services/local-inference/voice/rollback-queue.d.ts +24 -0
- package/services/local-inference/voice/rollback-queue.d.ts.map +1 -0
- package/services/local-inference/voice/rollback-queue.js +49 -0
- package/services/local-inference/voice/scheduler.d.ts +47 -0
- package/services/local-inference/voice/scheduler.d.ts.map +1 -0
- package/services/local-inference/voice/scheduler.js +123 -0
- package/services/local-inference/voice/shared-resources.d.ts +119 -0
- package/services/local-inference/voice/shared-resources.d.ts.map +1 -0
- package/services/local-inference/voice/shared-resources.js +83 -0
- package/services/local-inference/voice/speaker-preset-cache.d.ts +28 -0
- package/services/local-inference/voice/speaker-preset-cache.d.ts.map +1 -0
- package/services/local-inference/voice/speaker-preset-cache.js +44 -0
- package/services/local-inference/voice/types.d.ts +80 -0
- package/services/local-inference/voice/types.d.ts.map +1 -0
- package/services/local-inference/voice/voice-preset-format.d.ts +56 -0
- package/services/local-inference/voice/voice-preset-format.d.ts.map +1 -0
- package/services/local-inference/voice/voice-preset-format.js +184 -0
- package/services/persistence.d.ts +48 -0
- package/services/persistence.d.ts.map +1 -0
- package/services/persistence.js +128 -0
- package/services/plugin-installer.d.ts +22 -0
- package/services/plugin-installer.d.ts.map +1 -0
- package/services/plugin-installer.js +41 -0
- package/services/secrets-manager-installer.d.ts +140 -0
- package/services/secrets-manager-installer.d.ts.map +1 -0
- package/services/secrets-manager-installer.js +374 -0
- package/services/steward-credentials.d.ts +37 -0
- package/services/steward-credentials.d.ts.map +1 -0
- package/services/steward-credentials.js +93 -0
- package/services/steward-sidecar/health-check.d.ts +9 -0
- package/services/steward-sidecar/health-check.d.ts.map +1 -0
- package/services/steward-sidecar/health-check.js +34 -0
- package/services/steward-sidecar/helpers.d.ts +21 -0
- package/services/steward-sidecar/helpers.d.ts.map +1 -0
- package/services/steward-sidecar/helpers.js +71 -0
- package/services/steward-sidecar/process-management.d.ts +9 -0
- package/services/steward-sidecar/process-management.d.ts.map +1 -0
- package/services/steward-sidecar/process-management.js +53 -0
- package/services/steward-sidecar/types.d.ts +60 -0
- package/services/steward-sidecar/types.d.ts.map +1 -0
- package/services/steward-sidecar/types.js +17 -0
- package/services/steward-sidecar/wallet-setup.d.ts +9 -0
- package/services/steward-sidecar/wallet-setup.d.ts.map +1 -0
- package/services/steward-sidecar/wallet-setup.js +114 -0
- package/services/steward-sidecar.d.ts +70 -0
- package/services/steward-sidecar.d.ts.map +1 -0
- package/services/steward-sidecar.js +385 -0
- package/services/tool-call-cache/index.d.ts +13 -0
- package/services/tool-call-cache/index.d.ts.map +1 -0
- package/services/tool-call-cache/index.js +11 -0
- package/services/trigger-event-bridge.d.ts +52 -0
- package/services/trigger-event-bridge.d.ts.map +1 -0
- package/services/trigger-event-bridge.js +217 -0
- package/services/update-notifier.d.ts +6 -0
- package/services/update-notifier.d.ts.map +1 -0
- package/services/update-notifier.js +33 -0
- package/services/vault-bootstrap.d.ts +31 -0
- package/services/vault-bootstrap.d.ts.map +1 -0
- package/services/vault-bootstrap.js +209 -0
- package/services/vault-mirror.d.ts +44 -0
- package/services/vault-mirror.d.ts.map +1 -0
- package/services/vault-mirror.js +80 -0
- package/styles/electrobun-mac-window-drag.css +66 -0
- package/test/helpers/__tests__/live-agent-test.smoke.test.ts +105 -0
- package/test/helpers/action-assertions.ts +364 -0
- package/test/helpers/action-spy.ts +354 -0
- package/test/helpers/browser-launch.ts +103 -0
- package/test/helpers/browser-mocks.ts +275 -0
- package/test/helpers/conditional-tests.ts +42 -0
- package/test/helpers/conversation-harness.ts +334 -0
- package/test/helpers/http.ts +150 -0
- package/test/helpers/i18n.ts +5 -0
- package/test/helpers/isolated-config.ts +34 -0
- package/test/helpers/live-agent-test.ts +660 -0
- package/test/helpers/live-child-env.ts +72 -0
- package/test/helpers/live-provider.test.ts +124 -0
- package/test/helpers/live-provider.ts +362 -0
- package/test/helpers/live-runtime-server.ts +88 -0
- package/test/helpers/loopback.ts +33 -0
- package/test/helpers/pglite-runtime.ts +173 -0
- package/test/helpers/react-test.ts +40 -0
- package/test/helpers/real-connector.ts +250 -0
- package/test/helpers/real-runtime.ts +543 -0
- package/test/helpers/skip-without.ts +53 -0
- package/test/helpers/stochastic-test.ts +186 -0
- package/test/helpers/test-utils.ts +94 -0
- package/test/helpers/trajectory-assertions.ts +168 -0
- package/test/helpers/trajectory-harness.test.ts +101 -0
- package/test/helpers/trajectory-harness.ts +988 -0
- package/test/scripts/managed-test-command.mjs +632 -0
- package/test/scripts/task-agent-live-smoke.ts +1335 -0
- package/test/scripts/test-parallel.mjs +237 -0
- package/test/scripts/test-root-unit.mjs +169 -0
- package/test/scripts/test-runner.mjs +78 -0
- package/test/scripts/validate-all-features.sh +541 -0
- package/test-support/test-helpers.d.ts +111 -0
- package/test-support/test-helpers.d.ts.map +1 -0
- package/test-support/test-helpers.js +410 -0
- package/ui-compat.d.ts +3 -0
- package/ui-compat.d.ts.map +1 -0
- package/ui-compat.js +3 -0
- package/utils/eliza-root.d.ts +9 -0
- package/utils/eliza-root.d.ts.map +1 -0
- package/utils/eliza-root.js +101 -0
- package/utils/globals.d.ts +7 -0
- package/utils/globals.d.ts.map +1 -0
- package/utils/globals.js +47 -0
- package/App.d.ts +0 -5
- package/App.d.ts.map +0 -1
- package/App.js +0 -220
- package/LICENSE +0 -21
- package/actions/character.d.ts +0 -39
- package/actions/character.d.ts.map +0 -1
- package/actions/character.js +0 -247
- package/actions/chat-helpers.d.ts +0 -47
- package/actions/chat-helpers.d.ts.map +0 -1
- package/actions/chat-helpers.js +0 -79
- package/actions/cloud.d.ts +0 -17
- package/actions/cloud.d.ts.map +0 -1
- package/actions/cloud.js +0 -43
- package/actions/index.d.ts +0 -12
- package/actions/index.d.ts.map +0 -1
- package/actions/index.js +0 -11
- package/actions/lifecycle.d.ts +0 -43
- package/actions/lifecycle.d.ts.map +0 -1
- package/actions/lifecycle.js +0 -118
- package/actions/onboarding.d.ts +0 -13
- package/actions/onboarding.d.ts.map +0 -1
- package/actions/onboarding.js +0 -26
- package/actions/triggers.d.ts +0 -23
- package/actions/triggers.d.ts.map +0 -1
- package/actions/triggers.js +0 -148
- package/api/client.d.ts +0 -2742
- package/api/client.d.ts.map +0 -1
- package/api/client.js +0 -2520
- package/api/index.d.ts +0 -2
- package/api/index.d.ts.map +0 -1
- package/api/index.js +0 -1
- package/autonomy/index.d.ts +0 -48
- package/autonomy/index.d.ts.map +0 -1
- package/autonomy/index.js +0 -330
- package/bridge/capacitor-bridge.d.ts +0 -153
- package/bridge/capacitor-bridge.d.ts.map +0 -1
- package/bridge/capacitor-bridge.js +0 -193
- package/bridge/electrobun-rpc.d.ts +0 -28
- package/bridge/electrobun-rpc.d.ts.map +0 -1
- package/bridge/electrobun-rpc.js +0 -35
- package/bridge/electrobun-runtime.d.ts +0 -3
- package/bridge/electrobun-runtime.d.ts.map +0 -1
- package/bridge/electrobun-runtime.js +0 -17
- package/bridge/index.d.ts +0 -6
- package/bridge/index.d.ts.map +0 -1
- package/bridge/index.js +0 -5
- package/bridge/native-plugins.d.ts +0 -82
- package/bridge/native-plugins.d.ts.map +0 -1
- package/bridge/native-plugins.js +0 -39
- package/bridge/plugin-bridge.d.ts +0 -116
- package/bridge/plugin-bridge.d.ts.map +0 -1
- package/bridge/plugin-bridge.js +0 -203
- package/bridge/storage-bridge.d.ts +0 -39
- package/bridge/storage-bridge.d.ts.map +0 -1
- package/bridge/storage-bridge.js +0 -135
- package/chat/index.d.ts +0 -57
- package/chat/index.d.ts.map +0 -1
- package/chat/index.js +0 -160
- package/coding/index.d.ts +0 -25
- package/coding/index.d.ts.map +0 -1
- package/coding/index.js +0 -25
- package/components/AdvancedPageView.d.ts +0 -17
- package/components/AdvancedPageView.d.ts.map +0 -1
- package/components/AdvancedPageView.js +0 -146
- package/components/AgentActivityBox.d.ts +0 -7
- package/components/AgentActivityBox.d.ts.map +0 -1
- package/components/AgentActivityBox.js +0 -25
- package/components/ApiKeyConfig.d.ts +0 -26
- package/components/ApiKeyConfig.d.ts.map +0 -1
- package/components/ApiKeyConfig.js +0 -119
- package/components/AppsPageView.d.ts +0 -7
- package/components/AppsPageView.d.ts.map +0 -1
- package/components/AppsPageView.js +0 -31
- package/components/AppsView.d.ts +0 -8
- package/components/AppsView.d.ts.map +0 -1
- package/components/AppsView.js +0 -149
- package/components/AvatarLoader.d.ts +0 -13
- package/components/AvatarLoader.d.ts.map +0 -1
- package/components/AvatarLoader.js +0 -53
- package/components/AvatarSelector.d.ts +0 -23
- package/components/AvatarSelector.d.ts.map +0 -1
- package/components/AvatarSelector.js +0 -105
- package/components/BscTradePanel.d.ts +0 -22
- package/components/BscTradePanel.d.ts.map +0 -1
- package/components/BscTradePanel.js +0 -221
- package/components/BugReportModal.d.ts +0 -2
- package/components/BugReportModal.d.ts.map +0 -1
- package/components/BugReportModal.js +0 -219
- package/components/CharacterRoster.d.ts +0 -31
- package/components/CharacterRoster.d.ts.map +0 -1
- package/components/CharacterRoster.js +0 -41
- package/components/CharacterView.d.ts +0 -8
- package/components/CharacterView.d.ts.map +0 -1
- package/components/CharacterView.js +0 -685
- package/components/ChatAvatar.d.ts +0 -8
- package/components/ChatAvatar.d.ts.map +0 -1
- package/components/ChatAvatar.js +0 -89
- package/components/ChatComposer.d.ts +0 -37
- package/components/ChatComposer.d.ts.map +0 -1
- package/components/ChatComposer.js +0 -136
- package/components/ChatMessage.d.ts +0 -24
- package/components/ChatMessage.d.ts.map +0 -1
- package/components/ChatMessage.js +0 -187
- package/components/ChatModalView.d.ts +0 -10
- package/components/ChatModalView.d.ts.map +0 -1
- package/components/ChatModalView.js +0 -57
- package/components/ChatView.d.ts +0 -14
- package/components/ChatView.d.ts.map +0 -1
- package/components/ChatView.js +0 -526
- package/components/CloudOnboarding.d.ts +0 -7
- package/components/CloudOnboarding.d.ts.map +0 -1
- package/components/CloudOnboarding.js +0 -22
- package/components/CloudSourceControls.d.ts +0 -13
- package/components/CloudSourceControls.d.ts.map +0 -1
- package/components/CloudSourceControls.js +0 -16
- package/components/CodingAgentSettingsSection.d.ts +0 -8
- package/components/CodingAgentSettingsSection.d.ts.map +0 -1
- package/components/CodingAgentSettingsSection.js +0 -292
- package/components/CommandPalette.d.ts +0 -2
- package/components/CommandPalette.d.ts.map +0 -1
- package/components/CommandPalette.js +0 -181
- package/components/CompanionSceneHost.d.ts +0 -14
- package/components/CompanionSceneHost.d.ts.map +0 -1
- package/components/CompanionSceneHost.js +0 -362
- package/components/CompanionShell.d.ts +0 -17
- package/components/CompanionShell.d.ts.map +0 -1
- package/components/CompanionShell.js +0 -15
- package/components/CompanionView.d.ts +0 -2
- package/components/CompanionView.d.ts.map +0 -1
- package/components/CompanionView.js +0 -22
- package/components/ConfigPageView.d.ts +0 -11
- package/components/ConfigPageView.d.ts.map +0 -1
- package/components/ConfigPageView.js +0 -311
- package/components/ConfigSaveFooter.d.ts +0 -8
- package/components/ConfigSaveFooter.d.ts.map +0 -1
- package/components/ConfigSaveFooter.js +0 -10
- package/components/ConfirmModal.d.ts +0 -61
- package/components/ConfirmModal.d.ts.map +0 -1
- package/components/ConfirmModal.js +0 -164
- package/components/ConnectionFailedBanner.d.ts +0 -6
- package/components/ConnectionFailedBanner.d.ts.map +0 -1
- package/components/ConnectionFailedBanner.js +0 -22
- package/components/ConnectorsPageView.d.ts +0 -7
- package/components/ConnectorsPageView.d.ts.map +0 -1
- package/components/ConnectorsPageView.js +0 -8
- package/components/ConversationsSidebar.d.ts +0 -9
- package/components/ConversationsSidebar.d.ts.map +0 -1
- package/components/ConversationsSidebar.js +0 -116
- package/components/CustomActionEditor.d.ts +0 -10
- package/components/CustomActionEditor.d.ts.map +0 -1
- package/components/CustomActionEditor.js +0 -596
- package/components/CustomActionsPanel.d.ts +0 -9
- package/components/CustomActionsPanel.d.ts.map +0 -1
- package/components/CustomActionsPanel.js +0 -107
- package/components/CustomActionsView.d.ts +0 -2
- package/components/CustomActionsView.d.ts.map +0 -1
- package/components/CustomActionsView.js +0 -134
- package/components/DatabasePageView.d.ts +0 -5
- package/components/DatabasePageView.d.ts.map +0 -1
- package/components/DatabasePageView.js +0 -28
- package/components/DatabaseView.d.ts +0 -9
- package/components/DatabaseView.d.ts.map +0 -1
- package/components/DatabaseView.js +0 -311
- package/components/ElizaCloudDashboard.d.ts +0 -2
- package/components/ElizaCloudDashboard.d.ts.map +0 -1
- package/components/ElizaCloudDashboard.js +0 -657
- package/components/EmotePicker.d.ts +0 -2
- package/components/EmotePicker.d.ts.map +0 -1
- package/components/EmotePicker.js +0 -343
- package/components/ErrorBoundary.d.ts +0 -22
- package/components/ErrorBoundary.d.ts.map +0 -1
- package/components/ErrorBoundary.js +0 -31
- package/components/FineTuningView.d.ts +0 -2
- package/components/FineTuningView.d.ts.map +0 -1
- package/components/FineTuningView.js +0 -433
- package/components/FlaminaGuide.d.ts +0 -10
- package/components/FlaminaGuide.d.ts.map +0 -1
- package/components/FlaminaGuide.js +0 -64
- package/components/GameView.d.ts +0 -11
- package/components/GameView.d.ts.map +0 -1
- package/components/GameView.js +0 -294
- package/components/GameViewOverlay.d.ts +0 -8
- package/components/GameViewOverlay.d.ts.map +0 -1
- package/components/GameViewOverlay.js +0 -70
- package/components/GlobalEmoteOverlay.d.ts +0 -2
- package/components/GlobalEmoteOverlay.d.ts.map +0 -1
- package/components/GlobalEmoteOverlay.js +0 -112
- package/components/Header.d.ts +0 -9
- package/components/Header.d.ts.map +0 -1
- package/components/Header.js +0 -123
- package/components/HeartbeatsView.d.ts +0 -2
- package/components/HeartbeatsView.d.ts.map +0 -1
- package/components/HeartbeatsView.js +0 -378
- package/components/InventoryView.d.ts +0 -10
- package/components/InventoryView.d.ts.map +0 -1
- package/components/InventoryView.js +0 -176
- package/components/KnowledgeView.d.ts +0 -20
- package/components/KnowledgeView.d.ts.map +0 -1
- package/components/KnowledgeView.js +0 -483
- package/components/LanguageDropdown.d.ts +0 -30
- package/components/LanguageDropdown.d.ts.map +0 -1
- package/components/LanguageDropdown.js +0 -99
- package/components/LifoMonitorPanel.d.ts +0 -21
- package/components/LifoMonitorPanel.d.ts.map +0 -1
- package/components/LifoMonitorPanel.js +0 -24
- package/components/LifoSandboxView.d.ts +0 -5
- package/components/LifoSandboxView.d.ts.map +0 -1
- package/components/LifoSandboxView.js +0 -333
- package/components/LoadingScreen.d.ts +0 -13
- package/components/LoadingScreen.d.ts.map +0 -1
- package/components/LoadingScreen.js +0 -70
- package/components/LogsPageView.d.ts +0 -2
- package/components/LogsPageView.d.ts.map +0 -1
- package/components/LogsPageView.js +0 -7
- package/components/LogsView.d.ts +0 -5
- package/components/LogsView.d.ts.map +0 -1
- package/components/LogsView.js +0 -71
- package/components/MediaGalleryView.d.ts +0 -9
- package/components/MediaGalleryView.d.ts.map +0 -1
- package/components/MediaGalleryView.js +0 -236
- package/components/MediaSettingsSection.d.ts +0 -11
- package/components/MediaSettingsSection.d.ts.map +0 -1
- package/components/MediaSettingsSection.js +0 -329
- package/components/MessageContent.d.ts +0 -51
- package/components/MessageContent.d.ts.map +0 -1
- package/components/MessageContent.js +0 -553
- package/components/OnboardingWizard.d.ts +0 -2
- package/components/OnboardingWizard.d.ts.map +0 -1
- package/components/OnboardingWizard.js +0 -86
- package/components/PairingView.d.ts +0 -5
- package/components/PairingView.d.ts.map +0 -1
- package/components/PairingView.js +0 -29
- package/components/PermissionsSection.d.ts +0 -20
- package/components/PermissionsSection.d.ts.map +0 -1
- package/components/PermissionsSection.js +0 -573
- package/components/PluginsPageView.d.ts +0 -5
- package/components/PluginsPageView.d.ts.map +0 -1
- package/components/PluginsPageView.js +0 -8
- package/components/PluginsView.d.ts +0 -21
- package/components/PluginsView.d.ts.map +0 -1
- package/components/PluginsView.js +0 -1534
- package/components/ProviderSwitcher.d.ts +0 -42
- package/components/ProviderSwitcher.d.ts.map +0 -1
- package/components/ProviderSwitcher.js +0 -493
- package/components/RestartBanner.d.ts +0 -2
- package/components/RestartBanner.d.ts.map +0 -1
- package/components/RestartBanner.js +0 -36
- package/components/RuntimeView.d.ts +0 -10
- package/components/RuntimeView.d.ts.map +0 -1
- package/components/RuntimeView.js +0 -165
- package/components/SaveCommandModal.d.ts +0 -12
- package/components/SaveCommandModal.d.ts.map +0 -1
- package/components/SaveCommandModal.js +0 -84
- package/components/SecretsView.d.ts +0 -9
- package/components/SecretsView.d.ts.map +0 -1
- package/components/SecretsView.js +0 -249
- package/components/SettingsView.d.ts +0 -9
- package/components/SettingsView.d.ts.map +0 -1
- package/components/SettingsView.js +0 -230
- package/components/ShellOverlays.d.ts +0 -8
- package/components/ShellOverlays.d.ts.map +0 -1
- package/components/ShellOverlays.js +0 -10
- package/components/ShortcutsOverlay.d.ts +0 -2
- package/components/ShortcutsOverlay.d.ts.map +0 -1
- package/components/ShortcutsOverlay.js +0 -79
- package/components/SkillsView.d.ts +0 -11
- package/components/SkillsView.d.ts.map +0 -1
- package/components/SkillsView.js +0 -358
- package/components/StartupFailureView.d.ts +0 -8
- package/components/StartupFailureView.d.ts.map +0 -1
- package/components/StartupFailureView.js +0 -16
- package/components/StreamView.d.ts +0 -16
- package/components/StreamView.d.ts.map +0 -1
- package/components/StreamView.js +0 -300
- package/components/StripeEmbeddedCheckout.d.ts +0 -24
- package/components/StripeEmbeddedCheckout.d.ts.map +0 -1
- package/components/StripeEmbeddedCheckout.js +0 -101
- package/components/SubscriptionStatus.d.ts +0 -23
- package/components/SubscriptionStatus.d.ts.map +0 -1
- package/components/SubscriptionStatus.js +0 -301
- package/components/SystemWarningBanner.d.ts +0 -6
- package/components/SystemWarningBanner.d.ts.map +0 -1
- package/components/SystemWarningBanner.js +0 -46
- package/components/ThemeToggle.d.ts +0 -21
- package/components/ThemeToggle.d.ts.map +0 -1
- package/components/ThemeToggle.js +0 -24
- package/components/TrajectoriesView.d.ts +0 -12
- package/components/TrajectoriesView.d.ts.map +0 -1
- package/components/TrajectoriesView.js +0 -183
- package/components/TrajectoryDetailView.d.ts +0 -13
- package/components/TrajectoryDetailView.d.ts.map +0 -1
- package/components/TrajectoryDetailView.js +0 -112
- package/components/TriggersView.d.ts +0 -2
- package/components/TriggersView.d.ts.map +0 -1
- package/components/TriggersView.js +0 -1
- package/components/VectorBrowserView.d.ts +0 -10
- package/components/VectorBrowserView.d.ts.map +0 -1
- package/components/VectorBrowserView.js +0 -1000
- package/components/VoiceConfigView.d.ts +0 -11
- package/components/VoiceConfigView.d.ts.map +0 -1
- package/components/VoiceConfigView.js +0 -331
- package/components/VrmStage.d.ts +0 -28
- package/components/VrmStage.d.ts.map +0 -1
- package/components/VrmStage.js +0 -178
- package/components/WhatsAppQrOverlay.d.ts +0 -8
- package/components/WhatsAppQrOverlay.d.ts.map +0 -1
- package/components/WhatsAppQrOverlay.js +0 -63
- package/components/apps/AppDetailPane.d.ts +0 -15
- package/components/apps/AppDetailPane.d.ts.map +0 -1
- package/components/apps/AppDetailPane.js +0 -13
- package/components/apps/AppsCatalogGrid.d.ts +0 -20
- package/components/apps/AppsCatalogGrid.d.ts.map +0 -1
- package/components/apps/AppsCatalogGrid.js +0 -18
- package/components/apps/extensions/registry.d.ts +0 -4
- package/components/apps/extensions/registry.d.ts.map +0 -1
- package/components/apps/extensions/registry.js +0 -7
- package/components/apps/extensions/types.d.ts +0 -7
- package/components/apps/extensions/types.d.ts.map +0 -1
- package/components/apps/helpers.d.ts +0 -7
- package/components/apps/helpers.d.ts.map +0 -1
- package/components/apps/helpers.js +0 -44
- package/components/avatar/VrmAnimationLoader.d.ts +0 -30
- package/components/avatar/VrmAnimationLoader.d.ts.map +0 -1
- package/components/avatar/VrmAnimationLoader.js +0 -99
- package/components/avatar/VrmBlinkController.d.ts +0 -37
- package/components/avatar/VrmBlinkController.d.ts.map +0 -1
- package/components/avatar/VrmBlinkController.js +0 -98
- package/components/avatar/VrmCameraManager.d.ts +0 -57
- package/components/avatar/VrmCameraManager.d.ts.map +0 -1
- package/components/avatar/VrmCameraManager.js +0 -277
- package/components/avatar/VrmEngine.d.ts +0 -246
- package/components/avatar/VrmEngine.d.ts.map +0 -1
- package/components/avatar/VrmEngine.js +0 -2087
- package/components/avatar/VrmFootShadow.d.ts +0 -18
- package/components/avatar/VrmFootShadow.d.ts.map +0 -1
- package/components/avatar/VrmFootShadow.js +0 -83
- package/components/avatar/VrmViewer.d.ts +0 -60
- package/components/avatar/VrmViewer.d.ts.map +0 -1
- package/components/avatar/VrmViewer.js +0 -396
- package/components/avatar/mixamoVRMRigMap.d.ts +0 -3
- package/components/avatar/mixamoVRMRigMap.d.ts.map +0 -1
- package/components/avatar/mixamoVRMRigMap.js +0 -56
- package/components/avatar/retargetMixamoFbxToVrm.d.ts +0 -9
- package/components/avatar/retargetMixamoFbxToVrm.d.ts.map +0 -1
- package/components/avatar/retargetMixamoFbxToVrm.js +0 -88
- package/components/avatar/retargetMixamoGltfToVrm.d.ts +0 -11
- package/components/avatar/retargetMixamoGltfToVrm.d.ts.map +0 -1
- package/components/avatar/retargetMixamoGltfToVrm.js +0 -80
- package/components/chainConfig.d.ts +0 -89
- package/components/chainConfig.d.ts.map +0 -1
- package/components/chainConfig.js +0 -287
- package/components/companion/CompanionHeader.d.ts +0 -15
- package/components/companion/CompanionHeader.d.ts.map +0 -1
- package/components/companion/CompanionHeader.js +0 -7
- package/components/companion/CompanionSceneHost.d.ts +0 -2
- package/components/companion/CompanionSceneHost.d.ts.map +0 -1
- package/components/companion/CompanionSceneHost.js +0 -1
- package/components/companion/VrmStage.d.ts +0 -3
- package/components/companion/VrmStage.d.ts.map +0 -1
- package/components/companion/VrmStage.js +0 -1
- package/components/companion/index.d.ts +0 -18
- package/components/companion/index.d.ts.map +0 -1
- package/components/companion/index.js +0 -17
- package/components/companion/walletUtils.d.ts +0 -95
- package/components/companion/walletUtils.d.ts.map +0 -1
- package/components/companion/walletUtils.js +0 -167
- package/components/companion-shell-styles.d.ts +0 -38
- package/components/companion-shell-styles.d.ts.map +0 -1
- package/components/companion-shell-styles.js +0 -248
- package/components/confirm-delete-control.d.ts +0 -16
- package/components/confirm-delete-control.d.ts.map +0 -1
- package/components/confirm-delete-control.js +0 -12
- package/components/conversations/ConversationListItem.d.ts +0 -31
- package/components/conversations/ConversationListItem.d.ts.map +0 -1
- package/components/conversations/ConversationListItem.js +0 -52
- package/components/conversations/conversation-utils.d.ts +0 -9
- package/components/conversations/conversation-utils.d.ts.map +0 -1
- package/components/conversations/conversation-utils.js +0 -138
- package/components/format.d.ts +0 -54
- package/components/format.d.ts.map +0 -1
- package/components/format.js +0 -82
- package/components/index.d.ts +0 -96
- package/components/index.d.ts.map +0 -1
- package/components/index.js +0 -95
- package/components/inventory/CopyableAddress.d.ts +0 -8
- package/components/inventory/CopyableAddress.d.ts.map +0 -1
- package/components/inventory/CopyableAddress.js +0 -18
- package/components/inventory/InventoryToolbar.d.ts +0 -25
- package/components/inventory/InventoryToolbar.d.ts.map +0 -1
- package/components/inventory/InventoryToolbar.js +0 -28
- package/components/inventory/NftGrid.d.ts +0 -13
- package/components/inventory/NftGrid.d.ts.map +0 -1
- package/components/inventory/NftGrid.js +0 -29
- package/components/inventory/TokenLogo.d.ts +0 -12
- package/components/inventory/TokenLogo.d.ts.map +0 -1
- package/components/inventory/TokenLogo.js +0 -33
- package/components/inventory/TokensTable.d.ts +0 -24
- package/components/inventory/TokensTable.d.ts.map +0 -1
- package/components/inventory/TokensTable.js +0 -26
- package/components/inventory/constants.d.ts +0 -52
- package/components/inventory/constants.d.ts.map +0 -1
- package/components/inventory/constants.js +0 -121
- package/components/inventory/index.d.ts +0 -9
- package/components/inventory/index.d.ts.map +0 -1
- package/components/inventory/index.js +0 -8
- package/components/inventory/media-url.d.ts +0 -6
- package/components/inventory/media-url.d.ts.map +0 -1
- package/components/inventory/media-url.js +0 -28
- package/components/inventory/useInventoryData.d.ts +0 -53
- package/components/inventory/useInventoryData.d.ts.map +0 -1
- package/components/inventory/useInventoryData.js +0 -332
- package/components/knowledge-upload-image.d.ts +0 -27
- package/components/knowledge-upload-image.d.ts.map +0 -1
- package/components/knowledge-upload-image.js +0 -146
- package/components/labels.d.ts +0 -6
- package/components/labels.d.ts.map +0 -1
- package/components/labels.js +0 -40
- package/components/onboarding/ActivateStep.d.ts +0 -2
- package/components/onboarding/ActivateStep.d.ts.map +0 -1
- package/components/onboarding/ActivateStep.js +0 -10
- package/components/onboarding/CloudLoginStep.d.ts +0 -2
- package/components/onboarding/CloudLoginStep.d.ts.map +0 -1
- package/components/onboarding/CloudLoginStep.js +0 -20
- package/components/onboarding/ConnectionStep.d.ts +0 -2
- package/components/onboarding/ConnectionStep.d.ts.map +0 -1
- package/components/onboarding/ConnectionStep.js +0 -609
- package/components/onboarding/IdentityStep.d.ts +0 -2
- package/components/onboarding/IdentityStep.d.ts.map +0 -1
- package/components/onboarding/IdentityStep.js +0 -102
- package/components/onboarding/OnboardingPanel.d.ts +0 -9
- package/components/onboarding/OnboardingPanel.d.ts.map +0 -1
- package/components/onboarding/OnboardingPanel.js +0 -24
- package/components/onboarding/OnboardingStepNav.d.ts +0 -2
- package/components/onboarding/OnboardingStepNav.d.ts.map +0 -1
- package/components/onboarding/OnboardingStepNav.js +0 -24
- package/components/onboarding/PermissionsStep.d.ts +0 -2
- package/components/onboarding/PermissionsStep.d.ts.map +0 -1
- package/components/onboarding/PermissionsStep.js +0 -7
- package/components/onboarding/RpcStep.d.ts +0 -2
- package/components/onboarding/RpcStep.d.ts.map +0 -1
- package/components/onboarding/RpcStep.js +0 -125
- package/components/onboarding/SaveKeysStep.d.ts +0 -2
- package/components/onboarding/SaveKeysStep.d.ts.map +0 -1
- package/components/onboarding/SaveKeysStep.js +0 -44
- package/components/onboarding/WelcomeStep.d.ts +0 -2
- package/components/onboarding/WelcomeStep.d.ts.map +0 -1
- package/components/onboarding/WelcomeStep.js +0 -30
- package/components/permissions/PermissionIcon.d.ts +0 -4
- package/components/permissions/PermissionIcon.d.ts.map +0 -1
- package/components/permissions/PermissionIcon.js +0 -12
- package/components/permissions/StreamingPermissions.d.ts +0 -20
- package/components/permissions/StreamingPermissions.d.ts.map +0 -1
- package/components/permissions/StreamingPermissions.js +0 -178
- package/components/plugins/showcase-data.d.ts +0 -7
- package/components/plugins/showcase-data.d.ts.map +0 -1
- package/components/plugins/showcase-data.js +0 -464
- package/components/shared/ShellHeaderControls.d.ts +0 -27
- package/components/shared/ShellHeaderControls.d.ts.map +0 -1
- package/components/shared/ShellHeaderControls.js +0 -55
- package/components/shared-companion-scene-context.d.ts +0 -3
- package/components/shared-companion-scene-context.d.ts.map +0 -1
- package/components/shared-companion-scene-context.js +0 -13
- package/components/skeletons.d.ts +0 -17
- package/components/skeletons.d.ts.map +0 -1
- package/components/skeletons.js +0 -22
- package/components/stream/ActivityFeed.d.ts +0 -5
- package/components/stream/ActivityFeed.d.ts.map +0 -1
- package/components/stream/ActivityFeed.js +0 -57
- package/components/stream/AvatarPip.d.ts +0 -5
- package/components/stream/AvatarPip.d.ts.map +0 -1
- package/components/stream/AvatarPip.js +0 -6
- package/components/stream/ChatContent.d.ts +0 -6
- package/components/stream/ChatContent.d.ts.map +0 -1
- package/components/stream/ChatContent.js +0 -69
- package/components/stream/ChatTicker.d.ts +0 -5
- package/components/stream/ChatTicker.d.ts.map +0 -1
- package/components/stream/ChatTicker.js +0 -34
- package/components/stream/IdleContent.d.ts +0 -5
- package/components/stream/IdleContent.d.ts.map +0 -1
- package/components/stream/IdleContent.js +0 -17
- package/components/stream/StatusBar.d.ts +0 -36
- package/components/stream/StatusBar.d.ts.map +0 -1
- package/components/stream/StatusBar.js +0 -140
- package/components/stream/StreamSettings.d.ts +0 -33
- package/components/stream/StreamSettings.d.ts.map +0 -1
- package/components/stream/StreamSettings.js +0 -99
- package/components/stream/StreamTerminal.d.ts +0 -2
- package/components/stream/StreamTerminal.d.ts.map +0 -1
- package/components/stream/StreamTerminal.js +0 -52
- package/components/stream/StreamVoiceConfig.d.ts +0 -10
- package/components/stream/StreamVoiceConfig.d.ts.map +0 -1
- package/components/stream/StreamVoiceConfig.js +0 -88
- package/components/stream/helpers.d.ts +0 -32
- package/components/stream/helpers.d.ts.map +0 -1
- package/components/stream/helpers.js +0 -110
- package/components/stream/overlays/OverlayLayer.d.ts +0 -20
- package/components/stream/overlays/OverlayLayer.d.ts.map +0 -1
- package/components/stream/overlays/OverlayLayer.js +0 -24
- package/components/stream/overlays/built-in/ActionTickerWidget.d.ts +0 -8
- package/components/stream/overlays/built-in/ActionTickerWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/ActionTickerWidget.js +0 -44
- package/components/stream/overlays/built-in/AlertPopupWidget.d.ts +0 -7
- package/components/stream/overlays/built-in/AlertPopupWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/AlertPopupWidget.js +0 -62
- package/components/stream/overlays/built-in/BrandingWidget.d.ts +0 -7
- package/components/stream/overlays/built-in/BrandingWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/BrandingWidget.js +0 -36
- package/components/stream/overlays/built-in/CustomHtmlWidget.d.ts +0 -26
- package/components/stream/overlays/built-in/CustomHtmlWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/CustomHtmlWidget.js +0 -78
- package/components/stream/overlays/built-in/PeonGlassWidget.d.ts +0 -11
- package/components/stream/overlays/built-in/PeonGlassWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/PeonGlassWidget.js +0 -188
- package/components/stream/overlays/built-in/PeonHudWidget.d.ts +0 -10
- package/components/stream/overlays/built-in/PeonHudWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/PeonHudWidget.js +0 -168
- package/components/stream/overlays/built-in/PeonSakuraWidget.d.ts +0 -11
- package/components/stream/overlays/built-in/PeonSakuraWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/PeonSakuraWidget.js +0 -213
- package/components/stream/overlays/built-in/ThoughtBubbleWidget.d.ts +0 -8
- package/components/stream/overlays/built-in/ThoughtBubbleWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/ThoughtBubbleWidget.js +0 -59
- package/components/stream/overlays/built-in/ViewerCountWidget.d.ts +0 -7
- package/components/stream/overlays/built-in/ViewerCountWidget.d.ts.map +0 -1
- package/components/stream/overlays/built-in/ViewerCountWidget.js +0 -34
- package/components/stream/overlays/built-in/index.d.ts +0 -13
- package/components/stream/overlays/built-in/index.d.ts.map +0 -1
- package/components/stream/overlays/built-in/index.js +0 -12
- package/components/stream/overlays/registry.d.ts +0 -11
- package/components/stream/overlays/registry.d.ts.map +0 -1
- package/components/stream/overlays/registry.js +0 -16
- package/components/stream/overlays/types.d.ts +0 -67
- package/components/stream/overlays/types.d.ts.map +0 -1
- package/components/stream/overlays/types.js +0 -7
- package/components/stream/overlays/useOverlayLayout.d.ts +0 -27
- package/components/stream/overlays/useOverlayLayout.d.ts.map +0 -1
- package/components/stream/overlays/useOverlayLayout.js +0 -162
- package/components/trajectory-format.d.ts +0 -6
- package/components/trajectory-format.d.ts.map +0 -1
- package/components/trajectory-format.js +0 -43
- package/components/ui-badges.d.ts +0 -23
- package/components/ui-badges.d.ts.map +0 -1
- package/components/ui-badges.js +0 -38
- package/components/ui-switch.d.ts +0 -14
- package/components/ui-switch.d.ts.map +0 -1
- package/components/ui-switch.js +0 -15
- package/components/vector-browser-three.d.ts +0 -4
- package/components/vector-browser-three.d.ts.map +0 -1
- package/components/vector-browser-three.js +0 -21
- package/config/branding.d.ts +0 -49
- package/config/branding.d.ts.map +0 -1
- package/config/branding.js +0 -16
- package/config/config-catalog.d.ts +0 -376
- package/config/config-catalog.d.ts.map +0 -1
- package/config/config-catalog.js +0 -724
- package/config/config-field.d.ts +0 -68
- package/config/config-field.d.ts.map +0 -1
- package/config/config-field.js +0 -840
- package/config/config-renderer.d.ts +0 -176
- package/config/config-renderer.d.ts.map +0 -1
- package/config/config-renderer.js +0 -405
- package/config/index.d.ts +0 -6
- package/config/index.d.ts.map +0 -1
- package/config/index.js +0 -5
- package/config/ui-renderer.d.ts +0 -26
- package/config/ui-renderer.d.ts.map +0 -1
- package/config/ui-renderer.js +0 -815
- package/config/ui-spec.d.ts +0 -164
- package/config/ui-spec.d.ts.map +0 -1
- package/config/ui-spec.js +0 -13
- package/events/index.d.ts +0 -48
- package/events/index.d.ts.map +0 -1
- package/events/index.js +0 -45
- package/hooks/index.d.ts +0 -15
- package/hooks/index.d.ts.map +0 -1
- package/hooks/index.js +0 -14
- package/hooks/useBugReport.d.ts +0 -14
- package/hooks/useBugReport.d.ts.map +0 -1
- package/hooks/useBugReport.js +0 -18
- package/hooks/useCanvasWindow.d.ts +0 -38
- package/hooks/useCanvasWindow.d.ts.map +0 -1
- package/hooks/useCanvasWindow.js +0 -273
- package/hooks/useChatAvatarVoice.d.ts +0 -10
- package/hooks/useChatAvatarVoice.d.ts.map +0 -1
- package/hooks/useChatAvatarVoice.js +0 -71
- package/hooks/useClickOutside.d.ts +0 -6
- package/hooks/useClickOutside.d.ts.map +0 -1
- package/hooks/useClickOutside.js +0 -25
- package/hooks/useContextMenu.d.ts +0 -17
- package/hooks/useContextMenu.d.ts.map +0 -1
- package/hooks/useContextMenu.js +0 -100
- package/hooks/useKeyboardShortcuts.d.ts +0 -17
- package/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/hooks/useKeyboardShortcuts.js +0 -67
- package/hooks/useLifoSync.d.ts +0 -18
- package/hooks/useLifoSync.d.ts.map +0 -1
- package/hooks/useLifoSync.js +0 -113
- package/hooks/useMemoryMonitor.d.ts +0 -87
- package/hooks/useMemoryMonitor.d.ts.map +0 -1
- package/hooks/useMemoryMonitor.js +0 -209
- package/hooks/useRenderGuard.d.ts +0 -17
- package/hooks/useRenderGuard.d.ts.map +0 -1
- package/hooks/useRenderGuard.js +0 -36
- package/hooks/useRetakeCapture.d.ts +0 -12
- package/hooks/useRetakeCapture.d.ts.map +0 -1
- package/hooks/useRetakeCapture.js +0 -60
- package/hooks/useStreamPopoutNavigation.d.ts +0 -3
- package/hooks/useStreamPopoutNavigation.d.ts.map +0 -1
- package/hooks/useStreamPopoutNavigation.js +0 -17
- package/hooks/useTimeout.d.ts +0 -11
- package/hooks/useTimeout.d.ts.map +0 -1
- package/hooks/useTimeout.js +0 -32
- package/hooks/useVoiceChat.d.ts +0 -94
- package/hooks/useVoiceChat.d.ts.map +0 -1
- package/hooks/useVoiceChat.js +0 -1077
- package/hooks/useWhatsAppPairing.d.ts +0 -11
- package/hooks/useWhatsAppPairing.d.ts.map +0 -1
- package/hooks/useWhatsAppPairing.js +0 -95
- package/i18n/index.d.ts +0 -7
- package/i18n/index.d.ts.map +0 -1
- package/i18n/index.js +0 -53
- package/i18n/locales/en.json +0 -1268
- package/i18n/locales/es.json +0 -1236
- package/i18n/locales/ko.json +0 -1236
- package/i18n/locales/pt.json +0 -1236
- package/i18n/locales/zh-CN.json +0 -1236
- package/i18n/messages.d.ts +0 -6
- package/i18n/messages.d.ts.map +0 -1
- package/i18n/messages.js +0 -14
- package/navigation/index.d.ts +0 -27
- package/navigation/index.d.ts.map +0 -1
- package/navigation/index.js +0 -232
- package/onboarding-config.d.ts +0 -25
- package/onboarding-config.d.ts.map +0 -1
- package/onboarding-config.js +0 -76
- package/platform/browser-launch.d.ts +0 -2
- package/platform/browser-launch.d.ts.map +0 -1
- package/platform/browser-launch.js +0 -109
- package/platform/index.d.ts +0 -14
- package/platform/index.d.ts.map +0 -1
- package/platform/index.js +0 -24
- package/platform/init.d.ts +0 -40
- package/platform/init.d.ts.map +0 -1
- package/platform/init.js +0 -160
- package/platform/lifo.d.ts +0 -51
- package/platform/lifo.d.ts.map +0 -1
- package/platform/lifo.js +0 -138
- package/providers/index.d.ts +0 -19
- package/providers/index.d.ts.map +0 -1
- package/providers/index.js +0 -80
- package/shell-params.d.ts +0 -12
- package/shell-params.d.ts.map +0 -1
- package/shell-params.js +0 -19
- package/state/AppContext.d.ts +0 -12
- package/state/AppContext.d.ts.map +0 -1
- package/state/AppContext.js +0 -5102
- package/state/index.d.ts +0 -7
- package/state/index.d.ts.map +0 -1
- package/state/index.js +0 -6
- package/state/internal.d.ts +0 -7
- package/state/internal.d.ts.map +0 -1
- package/state/internal.js +0 -6
- package/state/onboarding-resume.d.ts +0 -11
- package/state/onboarding-resume.d.ts.map +0 -1
- package/state/onboarding-resume.js +0 -187
- package/state/parsers.d.ts +0 -26
- package/state/parsers.d.ts.map +0 -1
- package/state/parsers.js +0 -255
- package/state/persistence.d.ts +0 -59
- package/state/persistence.d.ts.map +0 -1
- package/state/persistence.js +0 -328
- package/state/shell-routing.d.ts +0 -12
- package/state/shell-routing.d.ts.map +0 -1
- package/state/shell-routing.js +0 -26
- package/state/types.d.ts +0 -426
- package/state/types.d.ts.map +0 -1
- package/state/types.js +0 -89
- package/state/ui-preferences.d.ts +0 -3
- package/state/ui-preferences.d.ts.map +0 -1
- package/state/ui-preferences.js +0 -1
- package/state/useApp.d.ts +0 -4
- package/state/useApp.d.ts.map +0 -1
- package/state/useApp.js +0 -22
- package/state/vrm.d.ts +0 -30
- package/state/vrm.d.ts.map +0 -1
- package/state/vrm.js +0 -82
- package/styles/anime.css +0 -6364
- package/styles/base.css +0 -255
- package/styles/onboarding-game.css +0 -1095
- package/styles/styles.css +0 -2087
- package/styles/xterm.css +0 -241
- package/types/index.d.ts +0 -657
- package/types/index.d.ts.map +0 -1
- package/types/index.js +0 -1
- package/utils/asset-url.d.ts +0 -26
- package/utils/asset-url.d.ts.map +0 -1
- package/utils/asset-url.js +0 -99
- package/utils/assistant-text.d.ts +0 -2
- package/utils/assistant-text.d.ts.map +0 -1
- package/utils/assistant-text.js +0 -161
- package/utils/clipboard.d.ts +0 -2
- package/utils/clipboard.d.ts.map +0 -1
- package/utils/clipboard.js +0 -38
- package/utils/desktop-dialogs.d.ts +0 -19
- package/utils/desktop-dialogs.d.ts.map +0 -1
- package/utils/desktop-dialogs.js +0 -50
- package/utils/eliza-globals.d.ts +0 -11
- package/utils/eliza-globals.d.ts.map +0 -1
- package/utils/eliza-globals.js +0 -33
- package/utils/index.d.ts +0 -8
- package/utils/index.d.ts.map +0 -1
- package/utils/index.js +0 -7
- package/utils/number-parsing.d.ts +0 -44
- package/utils/number-parsing.d.ts.map +0 -1
- package/utils/number-parsing.js +0 -56
- package/utils/openExternalUrl.d.ts +0 -2
- package/utils/openExternalUrl.d.ts.map +0 -1
- package/utils/openExternalUrl.js +0 -17
- package/utils/spoken-text.d.ts +0 -2
- package/utils/spoken-text.d.ts.map +0 -1
- package/utils/spoken-text.js +0 -56
- package/utils/streaming-text.d.ts +0 -3
- package/utils/streaming-text.d.ts.map +0 -1
- package/utils/streaming-text.js +0 -87
- package/voice/index.d.ts +0 -2
- package/voice/index.d.ts.map +0 -1
- package/voice/index.js +0 -1
- package/voice/types.d.ts +0 -25
- package/voice/types.d.ts.map +0 -1
- package/voice/types.js +0 -166
- package/wallet-rpc.d.ts +0 -8
- package/wallet-rpc.d.ts.map +0 -1
- package/wallet-rpc.js +0 -131
- /package/{components/apps/extensions → services/local-inference/voice}/types.js +0 -0
|
@@ -0,0 +1,2387 @@
|
|
|
1
|
+
diff --git a/LlamaCpp.podspec b/LlamaCpp.podspec
|
|
2
|
+
index fc84a44..35d9505 100644
|
|
3
|
+
--- a/LlamaCpp.podspec
|
|
4
|
+
+++ b/LlamaCpp.podspec
|
|
5
|
+
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
|
|
6
|
+
s.swift_version = '5.1'
|
|
7
|
+
|
|
8
|
+
# Include the native llama-cpp framework
|
|
9
|
+
- s.vendored_frameworks = 'ios/Frameworks/llama-cpp.framework'
|
|
10
|
+
+ s.vendored_frameworks = 'ios/Frameworks/LlamaCpp.framework'
|
|
11
|
+
end
|
|
12
|
+
diff --git a/LlamaCppCapacitor.podspec b/LlamaCppCapacitor.podspec
|
|
13
|
+
index 4b8af43..16b7823 100644
|
|
14
|
+
--- a/LlamaCppCapacitor.podspec
|
|
15
|
+
+++ b/LlamaCppCapacitor.podspec
|
|
16
|
+
@@ -16,8 +16,5 @@ Pod::Spec.new do |s|
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
|
|
19
|
+
# Include the native llama-cpp framework
|
|
20
|
+
- s.vendored_frameworks = 'ios/Frameworks/llama-cpp.framework'
|
|
21
|
+
- s.pod_target_xcconfig = {
|
|
22
|
+
- 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PODS_TARGET_SRCROOT)/ios/Frameworks"'
|
|
23
|
+
- }
|
|
24
|
+
+ s.vendored_frameworks = 'ios/Frameworks-xcframework/LlamaCpp.xcframework'
|
|
25
|
+
end
|
|
26
|
+
diff --git a/android/build.gradle b/android/build.gradle
|
|
27
|
+
index 772361a..c76814f 100644
|
|
28
|
+
--- a/android/build.gradle
|
|
29
|
+
+++ b/android/build.gradle
|
|
30
|
+
@@ -18,7 +18,7 @@ buildscript {
|
|
31
|
+
apply plugin: 'com.android.library'
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
- namespace "ai.annadata.plugin.capacitor"
|
|
35
|
+
+ namespace = "ai.annadata.plugin.capacitor"
|
|
36
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
37
|
+
defaultConfig {
|
|
38
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
39
|
+
@@ -35,21 +35,21 @@ android {
|
|
40
|
+
externalNativeBuild {
|
|
41
|
+
cmake {
|
|
42
|
+
path "src/main/CMakeLists.txt"
|
|
43
|
+
- version "3.22.1"
|
|
44
|
+
+ version = "3.22.1"
|
|
45
|
+
// Explicitly set NDK version to avoid Windows dependencies
|
|
46
|
+
- ndkVersion "29.0.13113456"
|
|
47
|
+
+ ndkVersion = "29.0.13113456"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
buildTypes {
|
|
52
|
+
release {
|
|
53
|
+
minifyEnabled false
|
|
54
|
+
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
55
|
+
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
lintOptions {
|
|
60
|
+
- abortOnError false
|
|
61
|
+
+ abortOnError = false
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
compileOptions {
|
|
65
|
+
diff --git a/android/src/main/jni.cpp b/android/src/main/jni.cpp
|
|
66
|
+
index 6377592..dd412fb 100644
|
|
67
|
+
--- a/android/src/main/jni.cpp
|
|
68
|
+
+++ b/android/src/main/jni.cpp
|
|
69
|
+
@@ -1481,19 +1481,22 @@ Java_ai_annadata_plugin_capacitor_LlamaCpp_embeddingNative(
|
|
70
|
+
if (params != nullptr) {
|
|
71
|
+
jclass jsObjectClass = env->GetObjectClass(params);
|
|
72
|
+
if (jsObjectClass != nullptr && !env->ExceptionCheck()) {
|
|
73
|
+
- // Try to get embd_normalize
|
|
74
|
+
- jmethodID getDoubleMethod = env->GetMethodID(jsObjectClass, "getDouble", "(Ljava/lang/String;)Ljava/lang/Double;");
|
|
75
|
+
- if (getDoubleMethod != nullptr && !env->ExceptionCheck()) {
|
|
76
|
+
+ // Capacitor 8 JSObject extends JSONObject and does not expose
|
|
77
|
+
+ // getDouble(String); use JSONObject's inherited optDouble
|
|
78
|
+
+ // signature so a missing helper cannot leave a pending JNI
|
|
79
|
+
+ // exception and abort the app after embedding completes.
|
|
80
|
+
+ jmethodID optDoubleMethod = env->GetMethodID(jsObjectClass, "optDouble", "(Ljava/lang/String;D)D");
|
|
81
|
+
+ if (env->ExceptionCheck()) {
|
|
82
|
+
+ env->ExceptionClear();
|
|
83
|
+
+ optDoubleMethod = nullptr;
|
|
84
|
+
+ }
|
|
85
|
+
+ if (optDoubleMethod != nullptr) {
|
|
86
|
+
jstring normalizeKey = jni_utils::string_to_jstring(env, "embd_normalize");
|
|
87
|
+
- jobject normalizeObj = env->CallObjectMethod(params, getDoubleMethod, normalizeKey);
|
|
88
|
+
- if (normalizeObj != nullptr && !env->ExceptionCheck()) {
|
|
89
|
+
- embd_normalize = env->CallDoubleMethod(normalizeObj,
|
|
90
|
+
- env->GetMethodID(env->FindClass("java/lang/Double"), "doubleValue", "()D"));
|
|
91
|
+
- env->DeleteLocalRef(normalizeObj);
|
|
92
|
+
- }
|
|
93
|
+
+ embd_normalize = env->CallDoubleMethod(params, optDoubleMethod, normalizeKey, embd_normalize);
|
|
94
|
+
env->DeleteLocalRef(normalizeKey);
|
|
95
|
+
if (env->ExceptionCheck()) {
|
|
96
|
+
env->ExceptionClear();
|
|
97
|
+
+ embd_normalize = 1.0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
diff --git a/build-native.sh b/build-native.sh
|
|
102
|
+
index 8909b49..b07f9e4 100755
|
|
103
|
+
--- a/build-native.sh
|
|
104
|
+
+++ b/build-native.sh
|
|
105
|
+
@@ -112,15 +112,23 @@ build_ios() {
|
|
106
|
+
|
|
107
|
+
# CMake builds the framework directly (FRAMEWORK TRUE in CMakeLists.txt)
|
|
108
|
+
# Verify the framework was created
|
|
109
|
+
- if [ -d "llama-cpp.framework" ]; then
|
|
110
|
+
- print_success "iOS framework built successfully at: $(pwd)/llama-cpp.framework"
|
|
111
|
+
+ if [ -d "LlamaCpp.framework" ] || [ -d "llama-cpp.framework" ]; then
|
|
112
|
+
+ FRAMEWORK_DIR="LlamaCpp.framework"
|
|
113
|
+
+ if [ ! -d "$FRAMEWORK_DIR" ]; then
|
|
114
|
+
+ FRAMEWORK_DIR="llama-cpp.framework"
|
|
115
|
+
+ fi
|
|
116
|
+
+ print_success "iOS framework built successfully at: $(pwd)/$FRAMEWORK_DIR"
|
|
117
|
+
|
|
118
|
+
# Binary location: CMake may produce flat (llama-cpp) or Versions/A/ layout
|
|
119
|
+
BINARY=""
|
|
120
|
+
- if [ -f "llama-cpp.framework/llama-cpp" ]; then
|
|
121
|
+
- BINARY="llama-cpp.framework/llama-cpp"
|
|
122
|
+
- elif [ -f "llama-cpp.framework/Versions/A/llama-cpp" ]; then
|
|
123
|
+
- BINARY="llama-cpp.framework/Versions/A/llama-cpp"
|
|
124
|
+
+ if [ -f "$FRAMEWORK_DIR/LlamaCpp" ]; then
|
|
125
|
+
+ BINARY="$FRAMEWORK_DIR/LlamaCpp"
|
|
126
|
+
+ elif [ -f "$FRAMEWORK_DIR/Versions/A/LlamaCpp" ]; then
|
|
127
|
+
+ BINARY="$FRAMEWORK_DIR/Versions/A/LlamaCpp"
|
|
128
|
+
+ elif [ -f "$FRAMEWORK_DIR/llama-cpp" ]; then
|
|
129
|
+
+ BINARY="$FRAMEWORK_DIR/llama-cpp"
|
|
130
|
+
+ elif [ -f "$FRAMEWORK_DIR/Versions/A/llama-cpp" ]; then
|
|
131
|
+
+ BINARY="$FRAMEWORK_DIR/Versions/A/llama-cpp"
|
|
132
|
+
fi
|
|
133
|
+
if [ -n "$BINARY" ]; then
|
|
134
|
+
if xcrun strip -x -S "$BINARY" 2>/dev/null; then
|
|
135
|
+
@@ -134,12 +142,28 @@ build_ios() {
|
|
136
|
+
cd ../..
|
|
137
|
+
return 1
|
|
138
|
+
fi
|
|
139
|
+
- rm -rf ../Frameworks/llama-cpp.framework
|
|
140
|
+
- mkdir -p ../Frameworks/llama-cpp.framework/Resources
|
|
141
|
+
- cp "$BINARY" ../Frameworks/llama-cpp.framework/llama-cpp
|
|
142
|
+
- [ -f llama-cpp.framework/Info.plist ] && cp llama-cpp.framework/Info.plist ../Frameworks/llama-cpp.framework/
|
|
143
|
+
- [ -f llama-cpp.framework/Versions/A/Resources/Info.plist ] && cp llama-cpp.framework/Versions/A/Resources/Info.plist ../Frameworks/llama-cpp.framework/Resources/
|
|
144
|
+
- print_success "iOS framework copied to ios/Frameworks/ for npm package (flat, no duplication)"
|
|
145
|
+
+ rm -rf ../Frameworks/LlamaCpp.framework ../Frameworks/llama-cpp.framework
|
|
146
|
+
+ mkdir -p ../Frameworks/LlamaCpp.framework/Headers ../Frameworks/LlamaCpp.framework/Modules
|
|
147
|
+
+ cp "$BINARY" ../Frameworks/LlamaCpp.framework/LlamaCpp
|
|
148
|
+
+ if [ -f "$FRAMEWORK_DIR/Info.plist" ]; then
|
|
149
|
+
+ cp "$FRAMEWORK_DIR/Info.plist" ../Frameworks/LlamaCpp.framework/
|
|
150
|
+
+ elif [ -f "$FRAMEWORK_DIR/Versions/A/Resources/Info.plist" ]; then
|
|
151
|
+
+ cp "$FRAMEWORK_DIR/Versions/A/Resources/Info.plist" ../Frameworks/LlamaCpp.framework/
|
|
152
|
+
+ fi
|
|
153
|
+
+ if command -v plutil >/dev/null 2>&1 && [ -f ../Frameworks/LlamaCpp.framework/Info.plist ]; then
|
|
154
|
+
+ plutil -replace CFBundleExecutable -string LlamaCpp ../Frameworks/LlamaCpp.framework/Info.plist
|
|
155
|
+
+ plutil -replace CFBundleIdentifier -string com.arusatech.LlamaCpp ../Frameworks/LlamaCpp.framework/Info.plist
|
|
156
|
+
+ plutil -replace CFBundleName -string LlamaCpp ../Frameworks/LlamaCpp.framework/Info.plist
|
|
157
|
+
+ fi
|
|
158
|
+
+ printf '' > ../Frameworks/LlamaCpp.framework/Headers/LlamaCpp.h
|
|
159
|
+
+ printf 'framework module LlamaCpp {\n umbrella header "LlamaCpp.h"\n export *\n}\n' > ../Frameworks/LlamaCpp.framework/Modules/module.modulemap
|
|
160
|
+
+ if command -v install_name_tool >/dev/null 2>&1; then
|
|
161
|
+
+ install_name_tool -id @rpath/LlamaCpp.framework/LlamaCpp ../Frameworks/LlamaCpp.framework/LlamaCpp 2>/dev/null || true
|
|
162
|
+
+ fi
|
|
163
|
+
+ if command -v codesign >/dev/null 2>&1; then
|
|
164
|
+
+ codesign --remove-signature ../Frameworks/LlamaCpp.framework/LlamaCpp 2>/dev/null || true
|
|
165
|
+
+ fi
|
|
166
|
+
+ print_success "iOS framework copied to ios/Frameworks/LlamaCpp.framework for npm package (flat, no duplication)"
|
|
167
|
+
else
|
|
168
|
+
print_error "iOS framework not found after build"
|
|
169
|
+
cd ../..
|
|
170
|
+
diff --git a/cpp/cap-bridge.cpp b/cpp/cap-bridge.cpp
|
|
171
|
+
new file mode 100644
|
|
172
|
+
index 0000000..e6bdbd5
|
|
173
|
+
--- /dev/null
|
|
174
|
+
+++ b/cpp/cap-bridge.cpp
|
|
175
|
+
@@ -0,0 +1,383 @@
|
|
176
|
+
+#include "cap-llama.h"
|
|
177
|
+
+#include "cap-completion.h"
|
|
178
|
+
+
|
|
179
|
+
+#include <chrono>
|
|
180
|
+
+#include <cstdlib>
|
|
181
|
+
+#include <cstring>
|
|
182
|
+
+#include <exception>
|
|
183
|
+
+#include <map>
|
|
184
|
+
+#include <memory>
|
|
185
|
+
+#include <mutex>
|
|
186
|
+
+#include <string>
|
|
187
|
+
+#include <vector>
|
|
188
|
+
+
|
|
189
|
+
+using json = nlohmann::ordered_json;
|
|
190
|
+
+
|
|
191
|
+
+namespace capllama {
|
|
192
|
+
+bool capllama_verbose = false;
|
|
193
|
+
+}
|
|
194
|
+
+
|
|
195
|
+
+namespace {
|
|
196
|
+
+
|
|
197
|
+
+std::map<int64_t, std::unique_ptr<capllama::llama_cap_context>> g_contexts;
|
|
198
|
+
+std::mutex g_contexts_mutex;
|
|
199
|
+
+std::string g_last_error;
|
|
200
|
+
+int64_t g_next_context_id = 1;
|
|
201
|
+
+
|
|
202
|
+
+char * copy_string(const std::string & value) {
|
|
203
|
+
+ char * out = static_cast<char *>(std::malloc(value.size() + 1));
|
|
204
|
+
+ if (out == nullptr) {
|
|
205
|
+
+ return nullptr;
|
|
206
|
+
+ }
|
|
207
|
+
+ std::memcpy(out, value.c_str(), value.size() + 1);
|
|
208
|
+
+ return out;
|
|
209
|
+
+}
|
|
210
|
+
+
|
|
211
|
+
+json parse_json(const char * input) {
|
|
212
|
+
+ if (input == nullptr || input[0] == '\0') {
|
|
213
|
+
+ return json::object();
|
|
214
|
+
+ }
|
|
215
|
+
+ try {
|
|
216
|
+
+ const auto parsed = json::parse(input, nullptr, false);
|
|
217
|
+
+ return parsed.is_discarded() || !parsed.is_object() ? json::object() : parsed;
|
|
218
|
+
+ } catch (...) {
|
|
219
|
+
+ return json::object();
|
|
220
|
+
+ }
|
|
221
|
+
+}
|
|
222
|
+
+
|
|
223
|
+
+bool get_bool(const json & value, const char * key, bool fallback) {
|
|
224
|
+
+ if (!value.contains(key) || value[key].is_null()) return fallback;
|
|
225
|
+
+ if (value[key].is_boolean()) return value[key].get<bool>();
|
|
226
|
+
+ if (value[key].is_number_integer()) return value[key].get<int>() != 0;
|
|
227
|
+
+ return fallback;
|
|
228
|
+
+}
|
|
229
|
+
+
|
|
230
|
+
+int get_int(const json & value, const char * key, int fallback) {
|
|
231
|
+
+ if (!value.contains(key) || value[key].is_null()) return fallback;
|
|
232
|
+
+ if (value[key].is_number_integer()) return value[key].get<int>();
|
|
233
|
+
+ if (value[key].is_number_float()) return static_cast<int>(value[key].get<double>());
|
|
234
|
+
+ return fallback;
|
|
235
|
+
+}
|
|
236
|
+
+
|
|
237
|
+
+float get_float(const json & value, const char * key, float fallback) {
|
|
238
|
+
+ if (!value.contains(key) || value[key].is_null()) return fallback;
|
|
239
|
+
+ if (value[key].is_number()) return value[key].get<float>();
|
|
240
|
+
+ return fallback;
|
|
241
|
+
+}
|
|
242
|
+
+
|
|
243
|
+
+std::string get_string(const json & value, const char * key, const std::string & fallback = "") {
|
|
244
|
+
+ if (!value.contains(key) || value[key].is_null()) return fallback;
|
|
245
|
+
+ if (value[key].is_string()) return value[key].get<std::string>();
|
|
246
|
+
+ return fallback;
|
|
247
|
+
+}
|
|
248
|
+
+
|
|
249
|
+
+void apply_context_params(common_params & params, const json & input, const std::string & model_path) {
|
|
250
|
+
+ params.model.path = model_path;
|
|
251
|
+
+ params.n_ctx = get_int(input, "n_ctx", params.n_ctx);
|
|
252
|
+
+ params.n_batch = get_int(input, "n_batch", params.n_batch);
|
|
253
|
+
+ params.n_ubatch = get_int(input, "n_ubatch", params.n_ubatch);
|
|
254
|
+
+ params.n_keep = get_int(input, "n_keep", params.n_keep);
|
|
255
|
+
+ params.n_gpu_layers = get_bool(input, "no_gpu_devices", false)
|
|
256
|
+
+ ? 0
|
|
257
|
+
+ : get_int(input, "n_gpu_layers", params.n_gpu_layers);
|
|
258
|
+
+ params.cpuparams.n_threads = get_int(input, "n_threads", params.cpuparams.n_threads);
|
|
259
|
+
+ params.use_mmap = get_bool(input, "use_mmap", params.use_mmap);
|
|
260
|
+
+ params.use_mlock = get_bool(input, "use_mlock", params.use_mlock);
|
|
261
|
+
+ params.ctx_shift = get_bool(input, "ctx_shift", params.ctx_shift);
|
|
262
|
+
+ params.flash_attn = get_bool(input, "flash_attn", params.flash_attn);
|
|
263
|
+
+ params.embedding = get_bool(input, "embedding", params.embedding);
|
|
264
|
+
+ params.chat_template = get_string(input, "chat_template", params.chat_template);
|
|
265
|
+
+ params.rope_freq_base = get_float(input, "rope_freq_base", params.rope_freq_base);
|
|
266
|
+
+ params.rope_freq_scale = get_float(input, "rope_freq_scale", params.rope_freq_scale);
|
|
267
|
+
+ params.yarn_ext_factor = get_float(input, "yarn_ext_factor", params.yarn_ext_factor);
|
|
268
|
+
+ params.yarn_attn_factor = get_float(input, "yarn_attn_factor", params.yarn_attn_factor);
|
|
269
|
+
+ params.yarn_beta_fast = get_float(input, "yarn_beta_fast", params.yarn_beta_fast);
|
|
270
|
+
+ params.yarn_beta_slow = get_float(input, "yarn_beta_slow", params.yarn_beta_slow);
|
|
271
|
+
+ params.yarn_orig_ctx = get_int(input, "yarn_orig_ctx", params.yarn_orig_ctx);
|
|
272
|
+
+
|
|
273
|
+
+ const std::string cache_type_k = get_string(input, "cache_type_k");
|
|
274
|
+
+ const std::string cache_type_v = get_string(input, "cache_type_v");
|
|
275
|
+
+ if (!cache_type_k.empty()) params.cache_type_k = capllama::kv_cache_type_from_str(cache_type_k);
|
|
276
|
+
+ if (!cache_type_v.empty()) params.cache_type_v = capllama::kv_cache_type_from_str(cache_type_v);
|
|
277
|
+
+
|
|
278
|
+
+ params.speculative.n_max = get_int(input, "speculative_samples", params.speculative.n_max);
|
|
279
|
+
+ params.speculative.n_max = get_int(input, "draft_max", params.speculative.n_max);
|
|
280
|
+
+ params.speculative.n_min = get_int(input, "draft_min", params.speculative.n_min);
|
|
281
|
+
+ params.speculative.model.path = get_string(input, "draft_model", params.speculative.model.path);
|
|
282
|
+
+}
|
|
283
|
+
+
|
|
284
|
+
+void apply_completion_params(common_params & params, const json & input, const char * prompt) {
|
|
285
|
+
+ params.prompt = prompt == nullptr ? "" : std::string(prompt);
|
|
286
|
+
+ params.n_predict = get_int(input, "n_predict", params.n_predict > 0 ? params.n_predict : 256);
|
|
287
|
+
+ params.cpuparams.n_threads = get_int(input, "n_threads", params.cpuparams.n_threads);
|
|
288
|
+
+ params.sampling.temp = get_float(input, "temperature", params.sampling.temp);
|
|
289
|
+
+ params.sampling.top_k = get_int(input, "top_k", params.sampling.top_k);
|
|
290
|
+
+ params.sampling.top_p = get_float(input, "top_p", params.sampling.top_p);
|
|
291
|
+
+ params.sampling.min_p = get_float(input, "min_p", params.sampling.min_p);
|
|
292
|
+
+ params.sampling.typ_p = get_float(input, "typical_p", params.sampling.typ_p);
|
|
293
|
+
+ params.sampling.penalty_repeat = get_float(input, "penalty_repeat", params.sampling.penalty_repeat);
|
|
294
|
+
+ params.sampling.penalty_freq = get_float(input, "penalty_freq", params.sampling.penalty_freq);
|
|
295
|
+
+ params.sampling.penalty_present = get_float(input, "penalty_present", params.sampling.penalty_present);
|
|
296
|
+
+ params.sampling.n_probs = get_int(input, "n_probs", params.sampling.n_probs);
|
|
297
|
+
+ params.sampling.seed = get_int(input, "seed", params.sampling.seed);
|
|
298
|
+
+
|
|
299
|
+
+ params.antiprompt.clear();
|
|
300
|
+
+ if (input.contains("stop") && input["stop"].is_array()) {
|
|
301
|
+
+ for (const auto & stop : input["stop"]) {
|
|
302
|
+
+ if (stop.is_string()) {
|
|
303
|
+
+ params.antiprompt.push_back(stop.get<std::string>());
|
|
304
|
+
+ }
|
|
305
|
+
+ }
|
|
306
|
+
+ }
|
|
307
|
+
+}
|
|
308
|
+
+
|
|
309
|
+
+json model_info_json(const capllama::llama_cap_context & ctx) {
|
|
310
|
+
+ char desc[256] = {0};
|
|
311
|
+
+ if (ctx.model != nullptr) {
|
|
312
|
+
+ llama_model_desc(ctx.model, desc, sizeof(desc));
|
|
313
|
+
+ }
|
|
314
|
+
+ json metadata = json::object();
|
|
315
|
+
+ if (ctx.model != nullptr) {
|
|
316
|
+
+ const int count = llama_model_meta_count(ctx.model);
|
|
317
|
+
+ char key[256] = {0};
|
|
318
|
+
+ char value[2048] = {0};
|
|
319
|
+
+ for (int i = 0; i < count; ++i) {
|
|
320
|
+
+ if (llama_model_meta_key_by_index(ctx.model, i, key, sizeof(key)) >= 0 &&
|
|
321
|
+
+ llama_model_meta_val_str_by_index(ctx.model, i, value, sizeof(value)) >= 0) {
|
|
322
|
+
+ metadata[key] = value;
|
|
323
|
+
+ }
|
|
324
|
+
+ }
|
|
325
|
+
+ }
|
|
326
|
+
+ return {
|
|
327
|
+
+ {"desc", desc[0] == '\0' ? "GGUF model" : desc},
|
|
328
|
+
+ {"size", ctx.model == nullptr ? 0 : llama_model_size(ctx.model)},
|
|
329
|
+
+ {"nEmbd", ctx.model == nullptr ? 0 : llama_model_n_embd(ctx.model)},
|
|
330
|
+
+ {"nParams", ctx.model == nullptr ? 0 : llama_model_n_params(ctx.model)},
|
|
331
|
+
+ {"metadata", metadata},
|
|
332
|
+
+ {"isChatTemplateSupported", true},
|
|
333
|
+
+ {"chatTemplates", {
|
|
334
|
+
+ {"llamaChat", true},
|
|
335
|
+
+ {"minja", {
|
|
336
|
+
+ {"default", true},
|
|
337
|
+
+ {"defaultCaps", {
|
|
338
|
+
+ {"tools", true},
|
|
339
|
+
+ {"toolCalls", true},
|
|
340
|
+
+ {"toolResponses", true},
|
|
341
|
+
+ {"systemRole", true},
|
|
342
|
+
+ {"parallelToolCalls", true},
|
|
343
|
+
+ {"toolCallId", true}
|
|
344
|
+
+ }},
|
|
345
|
+
+ {"toolUse", true},
|
|
346
|
+
+ {"toolUseCaps", {
|
|
347
|
+
+ {"tools", true},
|
|
348
|
+
+ {"toolCalls", true},
|
|
349
|
+
+ {"toolResponses", true},
|
|
350
|
+
+ {"systemRole", true},
|
|
351
|
+
+ {"parallelToolCalls", true},
|
|
352
|
+
+ {"toolCallId", true}
|
|
353
|
+
+ }}
|
|
354
|
+
+ }}
|
|
355
|
+
+ }}
|
|
356
|
+
+ };
|
|
357
|
+
+}
|
|
358
|
+
+
|
|
359
|
+
+json timings_json(const llama_perf_context_data & perf, size_t prompt_tokens, size_t predicted_tokens) {
|
|
360
|
+
+ const double prompt_ms = perf.t_p_eval_ms;
|
|
361
|
+
+ const double predicted_ms = perf.t_eval_ms;
|
|
362
|
+
+ return {
|
|
363
|
+
+ {"prompt_n", static_cast<int>(prompt_tokens)},
|
|
364
|
+
+ {"prompt_ms", prompt_ms},
|
|
365
|
+
+ {"prompt_per_token_ms", prompt_tokens > 0 ? prompt_ms / static_cast<double>(prompt_tokens) : 0.0},
|
|
366
|
+
+ {"prompt_per_second", prompt_ms > 0 ? 1000.0 * static_cast<double>(prompt_tokens) / prompt_ms : 0.0},
|
|
367
|
+
+ {"predicted_n", static_cast<int>(predicted_tokens)},
|
|
368
|
+
+ {"predicted_ms", predicted_ms},
|
|
369
|
+
+ {"predicted_per_token_ms", predicted_tokens > 0 ? predicted_ms / static_cast<double>(predicted_tokens) : 0.0},
|
|
370
|
+
+ {"predicted_per_second", predicted_ms > 0 ? 1000.0 * static_cast<double>(predicted_tokens) / predicted_ms : 0.0}
|
|
371
|
+
+ };
|
|
372
|
+
+}
|
|
373
|
+
+
|
|
374
|
+
+capllama::llama_cap_context * find_context_locked(int64_t context_id) {
|
|
375
|
+
+ const auto it = g_contexts.find(context_id);
|
|
376
|
+
+ if (it == g_contexts.end()) return nullptr;
|
|
377
|
+
+ return it->second.get();
|
|
378
|
+
+}
|
|
379
|
+
+
|
|
380
|
+
+} // namespace
|
|
381
|
+
+
|
|
382
|
+
+extern "C" char * llama_get_last_error(void) {
|
|
383
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
384
|
+
+ return copy_string(g_last_error.empty() ? "No detailed native error captured" : g_last_error);
|
|
385
|
+
+}
|
|
386
|
+
+
|
|
387
|
+
+extern "C" void llama_free_string(char * value) {
|
|
388
|
+
+ if (value != nullptr) {
|
|
389
|
+
+ std::free(value);
|
|
390
|
+
+ }
|
|
391
|
+
+}
|
|
392
|
+
+
|
|
393
|
+
+extern "C" int64_t llama_init_context(const char * model_path, const char * params_json) {
|
|
394
|
+
+ if (model_path == nullptr || model_path[0] == '\0') {
|
|
395
|
+
+ return -1;
|
|
396
|
+
+ }
|
|
397
|
+
+ try {
|
|
398
|
+
+ auto context = std::make_unique<capllama::llama_cap_context>();
|
|
399
|
+
+ common_params params;
|
|
400
|
+
+ apply_context_params(params, parse_json(params_json), model_path);
|
|
401
|
+
+ if (!context->loadModel(params)) {
|
|
402
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
403
|
+
+ g_last_error = std::string("Failed to load model: ") + model_path;
|
|
404
|
+
+ return -1;
|
|
405
|
+
+ }
|
|
406
|
+
+
|
|
407
|
+
+ const auto input = parse_json(params_json);
|
|
408
|
+
+ const std::string draft_model = get_string(input, "draft_model");
|
|
409
|
+
+ if (!draft_model.empty()) {
|
|
410
|
+
+ context->mobile_speculative = get_bool(input, "mobile_speculative", true);
|
|
411
|
+
+ context->speculative_samples = get_int(input, "speculative_samples", context->speculative_samples);
|
|
412
|
+
+ if (!context->loadDraftModel(draft_model)) {
|
|
413
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
414
|
+
+ g_last_error = "DFlash/speculative draft model loading is not available in this mobile framework build.";
|
|
415
|
+
+ return -1;
|
|
416
|
+
+ }
|
|
417
|
+
+ }
|
|
418
|
+
+
|
|
419
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
420
|
+
+ const int64_t context_id = g_next_context_id++;
|
|
421
|
+
+ g_contexts[context_id] = std::move(context);
|
|
422
|
+
+ return context_id;
|
|
423
|
+
+ } catch (const std::exception & e) {
|
|
424
|
+
+ capllama::log("ERROR", __func__, __LINE__, "llama_init_context failed: %s", e.what());
|
|
425
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
426
|
+
+ g_last_error = e.what();
|
|
427
|
+
+ return -1;
|
|
428
|
+
+ } catch (...) {
|
|
429
|
+
+ capllama::log("ERROR", __func__, __LINE__, "llama_init_context failed with unknown exception");
|
|
430
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
431
|
+
+ g_last_error = "llama_init_context failed with unknown exception";
|
|
432
|
+
+ return -1;
|
|
433
|
+
+ }
|
|
434
|
+
+}
|
|
435
|
+
+
|
|
436
|
+
+extern "C" void * llama_get_context_ptr(int64_t context_id) {
|
|
437
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
438
|
+
+ return find_context_locked(context_id);
|
|
439
|
+
+}
|
|
440
|
+
+
|
|
441
|
+
+extern "C" char * llama_get_model_info(int64_t context_id) {
|
|
442
|
+
+ try {
|
|
443
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
444
|
+
+ auto * ctx = find_context_locked(context_id);
|
|
445
|
+
+ if (ctx == nullptr) return nullptr;
|
|
446
|
+
+ return copy_string(model_info_json(*ctx).dump());
|
|
447
|
+
+ } catch (...) {
|
|
448
|
+
+ return nullptr;
|
|
449
|
+
+ }
|
|
450
|
+
+}
|
|
451
|
+
+
|
|
452
|
+
+extern "C" void llama_release_context(int64_t context_id) {
|
|
453
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
454
|
+
+ g_contexts.erase(context_id);
|
|
455
|
+
+}
|
|
456
|
+
+
|
|
457
|
+
+extern "C" char * llama_get_formatted_chat(int64_t context_id, const char * messages, const char * chat_template) {
|
|
458
|
+
+ try {
|
|
459
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
460
|
+
+ auto * ctx = find_context_locked(context_id);
|
|
461
|
+
+ if (ctx == nullptr) return nullptr;
|
|
462
|
+
+ const auto formatted = ctx->getFormattedChat(
|
|
463
|
+
+ messages == nullptr ? "[]" : messages,
|
|
464
|
+
+ chat_template == nullptr ? "" : chat_template
|
|
465
|
+
+ );
|
|
466
|
+
+ return copy_string(json(formatted).dump());
|
|
467
|
+
+ } catch (const std::exception & e) {
|
|
468
|
+
+ return copy_string(std::string("{\"error\":\"") + e.what() + "\"}");
|
|
469
|
+
+ } catch (...) {
|
|
470
|
+
+ return nullptr;
|
|
471
|
+
+ }
|
|
472
|
+
+}
|
|
473
|
+
+
|
|
474
|
+
+extern "C" char * llama_completion(int64_t context_id, const char * prompt, const char * params_json) {
|
|
475
|
+
+ const auto started = std::chrono::steady_clock::now();
|
|
476
|
+
+ try {
|
|
477
|
+
+ capllama::llama_cap_context * ctx = nullptr;
|
|
478
|
+
+ {
|
|
479
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
480
|
+
+ ctx = find_context_locked(context_id);
|
|
481
|
+
+ }
|
|
482
|
+
+ if (ctx == nullptr || ctx->ctx == nullptr || ctx->model == nullptr || ctx->completion == nullptr) {
|
|
483
|
+
+ return copy_string("{\"error\":\"Native context is not loaded\"}");
|
|
484
|
+
+ }
|
|
485
|
+
+
|
|
486
|
+
+ apply_completion_params(ctx->params, parse_json(params_json), prompt);
|
|
487
|
+
+ auto * completion = ctx->completion;
|
|
488
|
+
+ completion->rewind();
|
|
489
|
+
+ if (!completion->initSampling()) {
|
|
490
|
+
+ return copy_string("{\"error\":\"Failed to initialize sampler\"}");
|
|
491
|
+
+ }
|
|
492
|
+
+
|
|
493
|
+
+ completion->loadPrompt({});
|
|
494
|
+
+ completion->beginCompletion();
|
|
495
|
+
+ while (completion->has_next_token && !completion->is_interrupted) {
|
|
496
|
+
+ const size_t before_size = completion->generated_text.size();
|
|
497
|
+
+ if (ctx->isSpectulativeEnabled()) {
|
|
498
|
+
+ completion->nextTokenSpeculative();
|
|
499
|
+
+ } else {
|
|
500
|
+
+ completion->doCompletion();
|
|
501
|
+
+ }
|
|
502
|
+
+ const size_t last_token_size = completion->generated_text.size() - before_size;
|
|
503
|
+
+ const size_t stop_pos = completion->findStoppingStrings(completion->generated_text, last_token_size, capllama::STOP_FULL);
|
|
504
|
+
+ if (stop_pos != std::string::npos) {
|
|
505
|
+
+ completion->generated_text = completion->generated_text.substr(0, stop_pos);
|
|
506
|
+
+ }
|
|
507
|
+
+ }
|
|
508
|
+
+ completion->endCompletion();
|
|
509
|
+
+
|
|
510
|
+
+ std::string generated = completion->generated_text;
|
|
511
|
+
+
|
|
512
|
+
+ const auto perf = llama_perf_context(ctx->ctx);
|
|
513
|
+
+ const auto elapsed = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - started).count();
|
|
514
|
+
+ json result = {
|
|
515
|
+
+ {"text", generated},
|
|
516
|
+
+ {"content", generated},
|
|
517
|
+
+ {"reasoning_content", ""},
|
|
518
|
+
+ {"tool_calls", json::array()},
|
|
519
|
+
+ {"chat_format", completion->current_chat_format},
|
|
520
|
+
+ {"tokens_predicted", static_cast<int>(completion->num_tokens_predicted)},
|
|
521
|
+
+ {"tokens_evaluated", static_cast<int>(completion->num_prompt_tokens)},
|
|
522
|
+
+ {"truncated", completion->truncated},
|
|
523
|
+
+ {"stopped_eos", completion->stopped_eos},
|
|
524
|
+
+ {"stopped_word", completion->stopped_word},
|
|
525
|
+
+ {"stopped_limit", completion->stopped_limit},
|
|
526
|
+
+ {"stopping_word", completion->stopping_word},
|
|
527
|
+
+ {"context_full", completion->context_full},
|
|
528
|
+
+ {"interrupted", completion->is_interrupted},
|
|
529
|
+
+ {"tokens_cached", static_cast<int>(completion->n_past)},
|
|
530
|
+
+ {"timings", timings_json(perf, completion->num_prompt_tokens, completion->num_tokens_predicted)}
|
|
531
|
+
+ };
|
|
532
|
+
+ if (result["timings"]["predicted_ms"].get<double>() <= 0.0) {
|
|
533
|
+
+ result["timings"]["predicted_ms"] = elapsed;
|
|
534
|
+
+ result["timings"]["predicted_per_token_ms"] =
|
|
535
|
+
+ completion->num_tokens_predicted > 0 ? elapsed / static_cast<double>(completion->num_tokens_predicted) : 0.0;
|
|
536
|
+
+ result["timings"]["predicted_per_second"] =
|
|
537
|
+
+ elapsed > 0 ? 1000.0 * static_cast<double>(completion->num_tokens_predicted) / elapsed : 0.0;
|
|
538
|
+
+ }
|
|
539
|
+
+ return copy_string(result.dump());
|
|
540
|
+
+ } catch (const std::exception & e) {
|
|
541
|
+
+ return copy_string((json{{"error", e.what()}}).dump());
|
|
542
|
+
+ } catch (...) {
|
|
543
|
+
+ return copy_string("{\"error\":\"Unknown native completion failure\"}");
|
|
544
|
+
+ }
|
|
545
|
+
+}
|
|
546
|
+
+
|
|
547
|
+
+extern "C" void llama_stop_completion(int64_t context_id) {
|
|
548
|
+
+ std::lock_guard<std::mutex> lock(g_contexts_mutex);
|
|
549
|
+
+ auto * ctx = find_context_locked(context_id);
|
|
550
|
+
+ if (ctx != nullptr && ctx->completion != nullptr) {
|
|
551
|
+
+ ctx->completion->is_interrupted = true;
|
|
552
|
+
+ }
|
|
553
|
+
+}
|
|
554
|
+
+
|
|
555
|
+
+extern "C" bool llama_toggle_native_log(bool enabled) {
|
|
556
|
+
+ capllama::capllama_verbose = enabled;
|
|
557
|
+
+ return true;
|
|
558
|
+
+}
|
|
559
|
+
diff --git a/cpp/cap-embedding.cpp b/cpp/cap-embedding.cpp
|
|
560
|
+
index c6e0f56..968e58e 100644
|
|
561
|
+
--- a/cpp/cap-embedding.cpp
|
|
562
|
+
+++ b/cpp/cap-embedding.cpp
|
|
563
|
+
@@ -98,7 +98,7 @@ extern "C" float* llama_embedding(int64_t contextId, const char* text, const cha
|
|
564
|
+
|
|
565
|
+
// Add tokens to batch with embeddings enabled
|
|
566
|
+
for (size_t i = 0; i < tokens.size(); i++) {
|
|
567
|
+
- llama_batch_add(&batch, tokens[i], i, {0}, true); // logits=true to get embeddings
|
|
568
|
+
+ capllama::llama_batch_add(&batch, tokens[i], i, {0}, true); // logits=true to get embeddings
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Decode the batch to get embeddings
|
|
572
|
+
diff --git a/cpp/cap-llama.cpp b/cpp/cap-llama.cpp
|
|
573
|
+
index c65af7e..d205c90 100644
|
|
574
|
+
--- a/cpp/cap-llama.cpp
|
|
575
|
+
+++ b/cpp/cap-llama.cpp
|
|
576
|
+
@@ -368,9 +368,7 @@ bool llama_cap_context::loadDraftModel(const std::string &draft_model_path) {
|
|
577
|
+
// draft_model = llama_load_model_from_file(draft_model_path.c_str(), draft_params);
|
|
578
|
+
// draft_ctx = llama_new_context_with_model(draft_model, draft_params);
|
|
579
|
+
|
|
580
|
+
- // For this implementation, we'll disable speculative decoding
|
|
581
|
+
- // until proper model loading is implemented
|
|
582
|
+
- printf("Draft model loading not yet implemented - falling back to regular decoding\n");
|
|
583
|
+
+ printf("DFlash/speculative draft model loading is not available in this mobile framework build\n");
|
|
584
|
+
speculative_enabled = false;
|
|
585
|
+
return false;
|
|
586
|
+
|
|
587
|
+
diff --git a/ios/CMakeLists-arm64.txt b/ios/CMakeLists-arm64.txt
|
|
588
|
+
index c268b43..ba248b4 100644
|
|
589
|
+
--- a/ios/CMakeLists-arm64.txt
|
|
590
|
+
+++ b/ios/CMakeLists-arm64.txt
|
|
591
|
+
@@ -1,5 +1,5 @@
|
|
592
|
+
cmake_minimum_required(VERSION 3.16)
|
|
593
|
+
-project(llama-cpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
594
|
+
+project(LlamaCpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
595
|
+
|
|
596
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
597
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
598
|
+
@@ -36,7 +36,7 @@ set(PUBLIC_HEADERS
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
# Create library target
|
|
602
|
+
-add_library(llama-cpp SHARED
|
|
603
|
+
+add_library(LlamaCpp SHARED
|
|
604
|
+
${SOURCE_DIR}/ggml.c
|
|
605
|
+
${SOURCE_DIR}/ggml-alloc.c
|
|
606
|
+
${SOURCE_DIR}/ggml-backend.cpp
|
|
607
|
+
@@ -98,15 +98,18 @@ add_library(llama-cpp SHARED
|
|
608
|
+
${SOURCE_DIR}/tools/mtmd/clip.cpp
|
|
609
|
+
${SOURCE_DIR}/cap-llama.cpp
|
|
610
|
+
${SOURCE_DIR}/cap-completion.cpp
|
|
611
|
+
+ ${SOURCE_DIR}/cap-bridge.cpp
|
|
612
|
+
${SOURCE_DIR}/cap-tts.cpp
|
|
613
|
+
${SOURCE_FILES_ARCH}
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
+set_source_files_properties(${SOURCE_DIR}/cap-bridge.cpp PROPERTIES COMPILE_OPTIONS "-O0")
|
|
617
|
+
+
|
|
618
|
+
# Set target properties
|
|
619
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
620
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
621
|
+
FRAMEWORK TRUE
|
|
622
|
+
FRAMEWORK_VERSION A
|
|
623
|
+
- MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.llama-cpp
|
|
624
|
+
+ MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.LlamaCpp
|
|
625
|
+
MACOSX_FRAMEWORK_BUNDLE_VERSION 1.0.0
|
|
626
|
+
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.0.0
|
|
627
|
+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
|
628
|
+
@@ -116,7 +119,7 @@ set_target_properties(llama-cpp PROPERTIES
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
# Include directories
|
|
632
|
+
-target_include_directories(llama-cpp PRIVATE
|
|
633
|
+
+target_include_directories(LlamaCpp PRIVATE
|
|
634
|
+
${SOURCE_DIR}
|
|
635
|
+
${SOURCE_DIR}/ggml-cpu
|
|
636
|
+
${SOURCE_DIR}/tools/mtmd
|
|
637
|
+
@@ -125,7 +128,7 @@ target_include_directories(llama-cpp PRIVATE
|
|
638
|
+
# ARM64: rely on Clang's default tuning; no x86‑specific -march flags here
|
|
639
|
+
|
|
640
|
+
# Link frameworks via linker flags
|
|
641
|
+
-target_link_options(llama-cpp PRIVATE
|
|
642
|
+
+target_link_options(LlamaCpp PRIVATE
|
|
643
|
+
"-Wl,-framework,Accelerate"
|
|
644
|
+
"-Wl,-framework,Metal"
|
|
645
|
+
"-Wl,-framework,MetalKit"
|
|
646
|
+
@@ -134,16 +137,15 @@ target_link_options(llama-cpp PRIVATE
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
# Public headers
|
|
650
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
651
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
652
|
+
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
# Install rules
|
|
656
|
+
-install(TARGETS llama-cpp
|
|
657
|
+
+install(TARGETS LlamaCpp
|
|
658
|
+
FRAMEWORK DESTINATION .
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
-message(STATUS "Building llama-cpp for ARM64 (devices)")
|
|
662
|
+
+message(STATUS "Building LlamaCpp for ARM64 (devices)")
|
|
663
|
+
message(STATUS "Source directory: ${SOURCE_DIR}")
|
|
664
|
+
message(STATUS "Architecture: arm64")
|
|
665
|
+
-
|
|
666
|
+
diff --git a/ios/CMakeLists-x86_64.txt b/ios/CMakeLists-x86_64.txt
|
|
667
|
+
index b3652e9..054f5f3 100644
|
|
668
|
+
--- a/ios/CMakeLists-x86_64.txt
|
|
669
|
+
+++ b/ios/CMakeLists-x86_64.txt
|
|
670
|
+
@@ -1,5 +1,5 @@
|
|
671
|
+
cmake_minimum_required(VERSION 3.16)
|
|
672
|
+
-project(llama-cpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
673
|
+
+project(LlamaCpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
674
|
+
|
|
675
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
676
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
677
|
+
@@ -45,7 +45,7 @@ set(PUBLIC_HEADERS
|
|
678
|
+
)
|
|
679
|
+
|
|
680
|
+
# Create library target
|
|
681
|
+
-add_library(llama-cpp SHARED
|
|
682
|
+
+add_library(LlamaCpp SHARED
|
|
683
|
+
${SOURCE_DIR}/ggml.c
|
|
684
|
+
${SOURCE_DIR}/ggml-alloc.c
|
|
685
|
+
${SOURCE_DIR}/ggml-backend.cpp
|
|
686
|
+
@@ -111,15 +111,18 @@ add_library(llama-cpp SHARED
|
|
687
|
+
${SOURCE_DIR}/nlohmann/json_fwd.hpp
|
|
688
|
+
${SOURCE_DIR}/cap-llama.cpp
|
|
689
|
+
${SOURCE_DIR}/cap-completion.cpp
|
|
690
|
+
+ ${SOURCE_DIR}/cap-bridge.cpp
|
|
691
|
+
${SOURCE_DIR}/cap-tts.cpp
|
|
692
|
+
${SOURCE_FILES_ARCH}
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
+set_source_files_properties(${SOURCE_DIR}/cap-bridge.cpp PROPERTIES COMPILE_OPTIONS "-O0")
|
|
696
|
+
+
|
|
697
|
+
# Set target properties
|
|
698
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
699
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
700
|
+
FRAMEWORK TRUE
|
|
701
|
+
FRAMEWORK_VERSION A
|
|
702
|
+
- MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.llama-cpp
|
|
703
|
+
+ MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.LlamaCpp
|
|
704
|
+
MACOSX_FRAMEWORK_BUNDLE_VERSION 1.0.0
|
|
705
|
+
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.0.0
|
|
706
|
+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
|
707
|
+
@@ -129,14 +132,14 @@ set_target_properties(llama-cpp PROPERTIES
|
|
708
|
+
)
|
|
709
|
+
|
|
710
|
+
# Set include directories
|
|
711
|
+
-target_include_directories(llama-cpp PRIVATE
|
|
712
|
+
+target_include_directories(LlamaCpp PRIVATE
|
|
713
|
+
${SOURCE_DIR}
|
|
714
|
+
${SOURCE_DIR}/ggml-cpu
|
|
715
|
+
${SOURCE_DIR}/tools/mtmd
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
# Set compile options for x86_64 optimization
|
|
719
|
+
-target_compile_options(llama-cpp PRIVATE
|
|
720
|
+
+target_compile_options(LlamaCpp PRIVATE
|
|
721
|
+
-march=x86-64
|
|
722
|
+
-mtune=generic
|
|
723
|
+
-mavx2
|
|
724
|
+
@@ -151,7 +154,7 @@ target_compile_options(llama-cpp PRIVATE
|
|
725
|
+
# NOTE:
|
|
726
|
+
# Use -Wl,-framework,<Name> so that the compiler driver passes the correct
|
|
727
|
+
# framework flags through to the linker as a single option.
|
|
728
|
+
-target_link_options(llama-cpp PRIVATE
|
|
729
|
+
+target_link_options(LlamaCpp PRIVATE
|
|
730
|
+
"-Wl,-framework,Accelerate"
|
|
731
|
+
"-Wl,-framework,Metal"
|
|
732
|
+
"-Wl,-framework,MetalKit"
|
|
733
|
+
@@ -160,17 +163,17 @@ target_link_options(llama-cpp PRIVATE
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
# Set public headers
|
|
737
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
738
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
739
|
+
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
# Install rules
|
|
743
|
+
-install(TARGETS llama-cpp
|
|
744
|
+
+install(TARGETS LlamaCpp
|
|
745
|
+
FRAMEWORK DESTINATION .
|
|
746
|
+
)
|
|
747
|
+
|
|
748
|
+
# Print build information
|
|
749
|
+
-message(STATUS "Building llama-cpp for x86_64 (emulator)")
|
|
750
|
+
+message(STATUS "Building LlamaCpp for x86_64 (emulator)")
|
|
751
|
+
message(STATUS "Source directory: ${SOURCE_DIR}")
|
|
752
|
+
message(STATUS "Architecture: x86_64")
|
|
753
|
+
message(STATUS "Optimizations: AVX2, AVX, SSE3, SSE, FMA, F16C")
|
|
754
|
+
diff --git a/ios/CMakeLists.txt b/ios/CMakeLists.txt
|
|
755
|
+
index c268b43..ba248b4 100644
|
|
756
|
+
--- a/ios/CMakeLists.txt
|
|
757
|
+
+++ b/ios/CMakeLists.txt
|
|
758
|
+
@@ -1,5 +1,5 @@
|
|
759
|
+
cmake_minimum_required(VERSION 3.16)
|
|
760
|
+
-project(llama-cpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
761
|
+
+project(LlamaCpp VERSION 1.0.0 LANGUAGES CXX C)
|
|
762
|
+
|
|
763
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
764
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
765
|
+
@@ -36,7 +36,7 @@ set(PUBLIC_HEADERS
|
|
766
|
+
)
|
|
767
|
+
|
|
768
|
+
# Create library target
|
|
769
|
+
-add_library(llama-cpp SHARED
|
|
770
|
+
+add_library(LlamaCpp SHARED
|
|
771
|
+
${SOURCE_DIR}/ggml.c
|
|
772
|
+
${SOURCE_DIR}/ggml-alloc.c
|
|
773
|
+
${SOURCE_DIR}/ggml-backend.cpp
|
|
774
|
+
@@ -98,15 +98,18 @@ add_library(llama-cpp SHARED
|
|
775
|
+
${SOURCE_DIR}/tools/mtmd/clip.cpp
|
|
776
|
+
${SOURCE_DIR}/cap-llama.cpp
|
|
777
|
+
${SOURCE_DIR}/cap-completion.cpp
|
|
778
|
+
+ ${SOURCE_DIR}/cap-bridge.cpp
|
|
779
|
+
${SOURCE_DIR}/cap-tts.cpp
|
|
780
|
+
${SOURCE_FILES_ARCH}
|
|
781
|
+
)
|
|
782
|
+
|
|
783
|
+
+set_source_files_properties(${SOURCE_DIR}/cap-bridge.cpp PROPERTIES COMPILE_OPTIONS "-O0")
|
|
784
|
+
+
|
|
785
|
+
# Set target properties
|
|
786
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
787
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
788
|
+
FRAMEWORK TRUE
|
|
789
|
+
FRAMEWORK_VERSION A
|
|
790
|
+
- MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.llama-cpp
|
|
791
|
+
+ MACOSX_FRAMEWORK_IDENTIFIER com.arusatech.LlamaCpp
|
|
792
|
+
MACOSX_FRAMEWORK_BUNDLE_VERSION 1.0.0
|
|
793
|
+
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.0.0
|
|
794
|
+
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
|
795
|
+
@@ -116,7 +119,7 @@ set_target_properties(llama-cpp PROPERTIES
|
|
796
|
+
)
|
|
797
|
+
|
|
798
|
+
# Include directories
|
|
799
|
+
-target_include_directories(llama-cpp PRIVATE
|
|
800
|
+
+target_include_directories(LlamaCpp PRIVATE
|
|
801
|
+
${SOURCE_DIR}
|
|
802
|
+
${SOURCE_DIR}/ggml-cpu
|
|
803
|
+
${SOURCE_DIR}/tools/mtmd
|
|
804
|
+
@@ -125,7 +128,7 @@ target_include_directories(llama-cpp PRIVATE
|
|
805
|
+
# ARM64: rely on Clang's default tuning; no x86‑specific -march flags here
|
|
806
|
+
|
|
807
|
+
# Link frameworks via linker flags
|
|
808
|
+
-target_link_options(llama-cpp PRIVATE
|
|
809
|
+
+target_link_options(LlamaCpp PRIVATE
|
|
810
|
+
"-Wl,-framework,Accelerate"
|
|
811
|
+
"-Wl,-framework,Metal"
|
|
812
|
+
"-Wl,-framework,MetalKit"
|
|
813
|
+
@@ -134,16 +137,15 @@ target_link_options(llama-cpp PRIVATE
|
|
814
|
+
)
|
|
815
|
+
|
|
816
|
+
# Public headers
|
|
817
|
+
-set_target_properties(llama-cpp PROPERTIES
|
|
818
|
+
+set_target_properties(LlamaCpp PROPERTIES
|
|
819
|
+
PUBLIC_HEADER "${PUBLIC_HEADERS}"
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
# Install rules
|
|
823
|
+
-install(TARGETS llama-cpp
|
|
824
|
+
+install(TARGETS LlamaCpp
|
|
825
|
+
FRAMEWORK DESTINATION .
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
-message(STATUS "Building llama-cpp for ARM64 (devices)")
|
|
829
|
+
+message(STATUS "Building LlamaCpp for ARM64 (devices)")
|
|
830
|
+
message(STATUS "Source directory: ${SOURCE_DIR}")
|
|
831
|
+
message(STATUS "Architecture: arm64")
|
|
832
|
+
-
|
|
833
|
+
diff --git a/ios/Frameworks-xcframework/LlamaCpp.xcframework/Info.plist b/ios/Frameworks-xcframework/LlamaCpp.xcframework/Info.plist
|
|
834
|
+
new file mode 100644
|
|
835
|
+
index 0000000..ab641ec
|
|
836
|
+
--- /dev/null
|
|
837
|
+
+++ b/ios/Frameworks-xcframework/LlamaCpp.xcframework/Info.plist
|
|
838
|
+
@@ -0,0 +1,43 @@
|
|
839
|
+
+<?xml version="1.0" encoding="UTF-8"?>
|
|
840
|
+
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
841
|
+
+<plist version="1.0">
|
|
842
|
+
+<dict>
|
|
843
|
+
+ <key>AvailableLibraries</key>
|
|
844
|
+
+ <array>
|
|
845
|
+
+ <dict>
|
|
846
|
+
+ <key>BinaryPath</key>
|
|
847
|
+
+ <string>LlamaCpp.framework/LlamaCpp</string>
|
|
848
|
+
+ <key>LibraryIdentifier</key>
|
|
849
|
+
+ <string>ios-arm64</string>
|
|
850
|
+
+ <key>LibraryPath</key>
|
|
851
|
+
+ <string>LlamaCpp.framework</string>
|
|
852
|
+
+ <key>SupportedArchitectures</key>
|
|
853
|
+
+ <array>
|
|
854
|
+
+ <string>arm64</string>
|
|
855
|
+
+ </array>
|
|
856
|
+
+ <key>SupportedPlatform</key>
|
|
857
|
+
+ <string>ios</string>
|
|
858
|
+
+ </dict>
|
|
859
|
+
+ <dict>
|
|
860
|
+
+ <key>BinaryPath</key>
|
|
861
|
+
+ <string>LlamaCpp.framework/LlamaCpp</string>
|
|
862
|
+
+ <key>LibraryIdentifier</key>
|
|
863
|
+
+ <string>ios-arm64-simulator</string>
|
|
864
|
+
+ <key>LibraryPath</key>
|
|
865
|
+
+ <string>LlamaCpp.framework</string>
|
|
866
|
+
+ <key>SupportedArchitectures</key>
|
|
867
|
+
+ <array>
|
|
868
|
+
+ <string>arm64</string>
|
|
869
|
+
+ </array>
|
|
870
|
+
+ <key>SupportedPlatform</key>
|
|
871
|
+
+ <string>ios</string>
|
|
872
|
+
+ <key>SupportedPlatformVariant</key>
|
|
873
|
+
+ <string>simulator</string>
|
|
874
|
+
+ </dict>
|
|
875
|
+
+ </array>
|
|
876
|
+
+ <key>CFBundlePackageType</key>
|
|
877
|
+
+ <string>XFWK</string>
|
|
878
|
+
+ <key>XCFrameworkFormatVersion</key>
|
|
879
|
+
+ <string>1.0</string>
|
|
880
|
+
+</dict>
|
|
881
|
+
+</plist>
|
|
882
|
+
diff --git a/ios/Frameworks/llama-cpp.framework/Info.plist b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64-simulator/LlamaCpp.framework/Info.plist
|
|
883
|
+
similarity index 91%
|
|
884
|
+
rename from ios/Frameworks/llama-cpp.framework/Info.plist
|
|
885
|
+
rename to ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64-simulator/LlamaCpp.framework/Info.plist
|
|
886
|
+
index 79b6cdc..3740776 100644
|
|
887
|
+
--- a/ios/Frameworks/llama-cpp.framework/Info.plist
|
|
888
|
+
+++ b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64-simulator/LlamaCpp.framework/Info.plist
|
|
889
|
+
@@ -5,11 +5,11 @@
|
|
890
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
891
|
+
<string>English</string>
|
|
892
|
+
<key>CFBundleExecutable</key>
|
|
893
|
+
- <string>llama-cpp</string>
|
|
894
|
+
+ <string>LlamaCpp</string>
|
|
895
|
+
<key>CFBundleIconFile</key>
|
|
896
|
+
<string></string>
|
|
897
|
+
<key>CFBundleIdentifier</key>
|
|
898
|
+
- <string>com.arusatech.llama-cpp</string>
|
|
899
|
+
+ <string>com.arusatech.LlamaCpp</string>
|
|
900
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
901
|
+
<string>6.0</string>
|
|
902
|
+
<key>CFBundleName</key>
|
|
903
|
+
diff --git a/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Headers/LlamaCpp.h b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Headers/LlamaCpp.h
|
|
904
|
+
new file mode 100644
|
|
905
|
+
index 0000000..e69de29
|
|
906
|
+
diff --git a/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Info.plist b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Info.plist
|
|
907
|
+
new file mode 100644
|
|
908
|
+
index 0000000..c96f8fe
|
|
909
|
+
--- /dev/null
|
|
910
|
+
+++ b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Info.plist
|
|
911
|
+
@@ -0,0 +1,28 @@
|
|
912
|
+
+<?xml version="1.0" encoding="UTF-8"?>
|
|
913
|
+
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
914
|
+
+<plist version="1.0">
|
|
915
|
+
+<dict>
|
|
916
|
+
+ <key>CFBundleDevelopmentRegion</key>
|
|
917
|
+
+ <string>English</string>
|
|
918
|
+
+ <key>CFBundleExecutable</key>
|
|
919
|
+
+ <string>LlamaCpp</string>
|
|
920
|
+
+ <key>CFBundleIconFile</key>
|
|
921
|
+
+ <string></string>
|
|
922
|
+
+ <key>CFBundleIdentifier</key>
|
|
923
|
+
+ <string>com.arusatech.LlamaCpp</string>
|
|
924
|
+
+ <key>CFBundleInfoDictionaryVersion</key>
|
|
925
|
+
+ <string>6.0</string>
|
|
926
|
+
+ <key>CFBundleName</key>
|
|
927
|
+
+ <string>LlamaCpp</string>
|
|
928
|
+
+ <key>CFBundlePackageType</key>
|
|
929
|
+
+ <string>FMWK</string>
|
|
930
|
+
+ <key>CFBundleShortVersionString</key>
|
|
931
|
+
+ <string>1.0.0</string>
|
|
932
|
+
+ <key>CFBundleSignature</key>
|
|
933
|
+
+ <string>????</string>
|
|
934
|
+
+ <key>CFBundleVersion</key>
|
|
935
|
+
+ <string>1.0.0</string>
|
|
936
|
+
+ <key>CSResourcesFileMapped</key>
|
|
937
|
+
+ <true/>
|
|
938
|
+
+</dict>
|
|
939
|
+
+</plist>
|
|
940
|
+
diff --git a/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Modules/module.modulemap b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Modules/module.modulemap
|
|
941
|
+
new file mode 100644
|
|
942
|
+
index 0000000..964fc83
|
|
943
|
+
--- /dev/null
|
|
944
|
+
+++ b/ios/Frameworks-xcframework/LlamaCpp.xcframework/ios-arm64/LlamaCpp.framework/Modules/module.modulemap
|
|
945
|
+
@@ -0,0 +1,4 @@
|
|
946
|
+
+framework module LlamaCpp {
|
|
947
|
+
+ umbrella header "LlamaCpp.h"
|
|
948
|
+
+ export *
|
|
949
|
+
+}
|
|
950
|
+
diff --git a/ios/Sources/LlamaCppPlugin/LlamaCpp.swift b/ios/Sources/LlamaCppPlugin/LlamaCpp.swift
|
|
951
|
+
index 98f0ad0..a20a549 100644
|
|
952
|
+
--- a/ios/Sources/LlamaCppPlugin/LlamaCpp.swift
|
|
953
|
+
+++ b/ios/Sources/LlamaCppPlugin/LlamaCpp.swift
|
|
954
|
+
@@ -1,50 +1,127 @@
|
|
955
|
+
import Foundation
|
|
956
|
+
import Capacitor
|
|
957
|
+
+import Darwin
|
|
958
|
+
|
|
959
|
+
// MARK: - Native Library Integration
|
|
960
|
+
private var contexts: [Int64: UnsafeMutableRawPointer] = [:]
|
|
961
|
+
private var nextContextId: Int64 = 1
|
|
962
|
+
|
|
963
|
+
+private typealias NativeInitContext = @convention(c) (UnsafePointer<CChar>, UnsafePointer<CChar>) -> Int64
|
|
964
|
+
+private typealias NativeReleaseContext = @convention(c) (Int64) -> Void
|
|
965
|
+
+private typealias NativeCompletion = @convention(c) (Int64, UnsafePointer<CChar>, UnsafePointer<CChar>) -> UnsafeMutablePointer<CChar>?
|
|
966
|
+
+private typealias NativeStopCompletion = @convention(c) (Int64) -> Void
|
|
967
|
+
+private typealias NativeGetFormattedChat = @convention(c) (Int64, UnsafePointer<CChar>, UnsafePointer<CChar>) -> UnsafeMutablePointer<CChar>?
|
|
968
|
+
+private typealias NativeToggleLog = @convention(c) (Bool) -> Bool
|
|
969
|
+
+private typealias NativeEmbedding = @convention(c) (Int64, UnsafePointer<CChar>, UnsafePointer<CChar>) -> UnsafePointer<Float>?
|
|
970
|
+
+private typealias NativeRegisterEmbeddingContext = @convention(c) (Int64, UnsafeMutableRawPointer) -> Void
|
|
971
|
+
+private typealias NativeUnregisterEmbeddingContext = @convention(c) (Int64) -> Void
|
|
972
|
+
+private typealias NativeGetModelInfo = @convention(c) (Int64) -> UnsafeMutablePointer<CChar>?
|
|
973
|
+
+private typealias NativeGetContextPtr = @convention(c) (Int64) -> UnsafeMutableRawPointer?
|
|
974
|
+
+private typealias NativeGetLastError = @convention(c) () -> UnsafeMutablePointer<CChar>?
|
|
975
|
+
+private typealias NativeFreeString = @convention(c) (UnsafeMutablePointer<CChar>?) -> Void
|
|
976
|
+
+
|
|
977
|
+
// Load the native library (use enum to avoid lazy-on-global Swift error)
|
|
978
|
+
private enum LibraryLoader {
|
|
979
|
+
static var llamaLibrary: UnsafeMutableRawPointer? = {
|
|
980
|
+
- guard let libraryPath = Bundle.main.path(forResource: "llama-cpp", ofType: "framework") else {
|
|
981
|
+
- print("Error: llama-cpp framework not found")
|
|
982
|
+
- return nil
|
|
983
|
+
+ var candidates: [String] = []
|
|
984
|
+
+ if let frameworkPath = Bundle.main.path(forResource: "LlamaCpp", ofType: "framework") {
|
|
985
|
+
+ candidates.append((frameworkPath as NSString).appendingPathComponent("LlamaCpp"))
|
|
986
|
+
+ candidates.append(frameworkPath)
|
|
987
|
+
+ }
|
|
988
|
+
+ if let privateFrameworkURL = Bundle.main.privateFrameworksURL?.appendingPathComponent("LlamaCpp.framework/LlamaCpp") {
|
|
989
|
+
+ candidates.append(privateFrameworkURL.path)
|
|
990
|
+
+ }
|
|
991
|
+
+ if let frameworkPath = Bundle.main.path(forResource: "llama-cpp", ofType: "framework") {
|
|
992
|
+
+ candidates.append((frameworkPath as NSString).appendingPathComponent("llama-cpp"))
|
|
993
|
+
+ candidates.append(frameworkPath)
|
|
994
|
+
+ }
|
|
995
|
+
+ if let privateFrameworkURL = Bundle.main.privateFrameworksURL?.appendingPathComponent("llama-cpp.framework/llama-cpp") {
|
|
996
|
+
+ candidates.append(privateFrameworkURL.path)
|
|
997
|
+
}
|
|
998
|
+
- guard let handle = dlopen(libraryPath, RTLD_NOW) else {
|
|
999
|
+
- print("Error: Failed to load llama-cpp library: \(String(cString: dlerror()))")
|
|
1000
|
+
- return nil
|
|
1001
|
+
+ for path in candidates where FileManager.default.fileExists(atPath: path) {
|
|
1002
|
+
+ if let handle = dlopen(path, RTLD_NOW | RTLD_GLOBAL) {
|
|
1003
|
+
+ return handle
|
|
1004
|
+
+ }
|
|
1005
|
+
+ if let error = dlerror() {
|
|
1006
|
+
+ print("Error: Failed to load llama-cpp library at \(path): \(String(cString: error))")
|
|
1007
|
+
+ }
|
|
1008
|
+
}
|
|
1009
|
+
- return handle
|
|
1010
|
+
+ print("Error: llama-cpp framework binary not found")
|
|
1011
|
+
+ return nil
|
|
1012
|
+
}()
|
|
1013
|
+
}
|
|
1014
|
+
private var llamaLibrary: UnsafeMutableRawPointer? { LibraryLoader.llamaLibrary }
|
|
1015
|
+
|
|
1016
|
+
// Function pointers for native calls
|
|
1017
|
+
-private var initContextFunc: ((String, UnsafePointer<Int8>) -> Int64)?
|
|
1018
|
+
-private var releaseContextFunc: ((Int64) -> Void)?
|
|
1019
|
+
-private var completionFunc: ((Int64, String, UnsafePointer<Int8>) -> String?)?
|
|
1020
|
+
-private var stopCompletionFunc: ((Int64) -> Void)?
|
|
1021
|
+
-private var getFormattedChatFunc: ((Int64, String, String) -> String?)?
|
|
1022
|
+
-private var toggleNativeLogFunc: ((Bool) -> Bool)?
|
|
1023
|
+
-private var embeddingFunc: ((Int64, String, UnsafePointer<Int8>) -> UnsafePointer<Float>?)?
|
|
1024
|
+
-private var registerEmbeddingContextFunc: ((Int64, UnsafeMutableRawPointer) -> Void)?
|
|
1025
|
+
-private var unregisterEmbeddingContextFunc: ((Int64) -> Void)?
|
|
1026
|
+
+private var initContextFunc: NativeInitContext?
|
|
1027
|
+
+private var releaseContextFunc: NativeReleaseContext?
|
|
1028
|
+
+private var completionFunc: NativeCompletion?
|
|
1029
|
+
+private var stopCompletionFunc: NativeStopCompletion?
|
|
1030
|
+
+private var getFormattedChatFunc: NativeGetFormattedChat?
|
|
1031
|
+
+private var toggleNativeLogFunc: NativeToggleLog?
|
|
1032
|
+
+private var embeddingFunc: NativeEmbedding?
|
|
1033
|
+
+private var registerEmbeddingContextFunc: NativeRegisterEmbeddingContext?
|
|
1034
|
+
+private var unregisterEmbeddingContextFunc: NativeUnregisterEmbeddingContext?
|
|
1035
|
+
+private var getModelInfoFunc: NativeGetModelInfo?
|
|
1036
|
+
+private var getContextPtrFunc: NativeGetContextPtr?
|
|
1037
|
+
+private var getLastErrorFunc: NativeGetLastError?
|
|
1038
|
+
+private var freeStringFunc: NativeFreeString?
|
|
1039
|
+
+
|
|
1040
|
+
+private func loadSymbol<T>(_ name: String, as type: T.Type) -> T? {
|
|
1041
|
+
+ guard let library = llamaLibrary else { return nil }
|
|
1042
|
+
+ guard let symbol = dlsym(library, name) else {
|
|
1043
|
+
+ print("Error: native symbol \(name) not found")
|
|
1044
|
+
+ return nil
|
|
1045
|
+
+ }
|
|
1046
|
+
+ return unsafeBitCast(symbol, to: type)
|
|
1047
|
+
+}
|
|
1048
|
+
|
|
1049
|
+
private func loadFunctionPointers() {
|
|
1050
|
+
- guard let library = llamaLibrary else { return }
|
|
1051
|
+
-
|
|
1052
|
+
- // Load function pointers from the native library
|
|
1053
|
+
- initContextFunc = unsafeBitCast(dlsym(library, "llama_init_context"), to: ((String, UnsafePointer<Int8>) -> Int64).self)
|
|
1054
|
+
- releaseContextFunc = unsafeBitCast(dlsym(library, "llama_release_context"), to: ((Int64) -> Void).self)
|
|
1055
|
+
- completionFunc = unsafeBitCast(dlsym(library, "llama_completion"), to: ((Int64, String, UnsafePointer<Int8>) -> String?).self)
|
|
1056
|
+
- stopCompletionFunc = unsafeBitCast(dlsym(library, "llama_stop_completion"), to: ((Int64) -> Void).self)
|
|
1057
|
+
- getFormattedChatFunc = unsafeBitCast(dlsym(library, "llama_get_formatted_chat"), to: ((Int64, String, String) -> String?).self)
|
|
1058
|
+
- toggleNativeLogFunc = unsafeBitCast(dlsym(library, "llama_toggle_native_log"), to: ((Bool) -> Bool).self)
|
|
1059
|
+
- embeddingFunc = unsafeBitCast(dlsym(library, "llama_embedding"), to: ((Int64, String, UnsafePointer<Int8>) -> UnsafePointer<Float>?).self)
|
|
1060
|
+
- registerEmbeddingContextFunc = unsafeBitCast(dlsym(library, "llama_embedding_register_context"), to: ((Int64, UnsafeMutableRawPointer) -> Void).self)
|
|
1061
|
+
- unregisterEmbeddingContextFunc = unsafeBitCast(dlsym(library, "llama_embedding_unregister_context"), to: ((Int64) -> Void).self)
|
|
1062
|
+
+ initContextFunc = loadSymbol("llama_init_context", as: NativeInitContext.self)
|
|
1063
|
+
+ releaseContextFunc = loadSymbol("llama_release_context", as: NativeReleaseContext.self)
|
|
1064
|
+
+ completionFunc = loadSymbol("llama_completion", as: NativeCompletion.self)
|
|
1065
|
+
+ stopCompletionFunc = loadSymbol("llama_stop_completion", as: NativeStopCompletion.self)
|
|
1066
|
+
+ getFormattedChatFunc = loadSymbol("llama_get_formatted_chat", as: NativeGetFormattedChat.self)
|
|
1067
|
+
+ toggleNativeLogFunc = loadSymbol("llama_toggle_native_log", as: NativeToggleLog.self)
|
|
1068
|
+
+ embeddingFunc = loadSymbol("llama_embedding", as: NativeEmbedding.self)
|
|
1069
|
+
+ registerEmbeddingContextFunc = loadSymbol("llama_embedding_register_context", as: NativeRegisterEmbeddingContext.self)
|
|
1070
|
+
+ unregisterEmbeddingContextFunc = loadSymbol("llama_embedding_unregister_context", as: NativeUnregisterEmbeddingContext.self)
|
|
1071
|
+
+ getModelInfoFunc = loadSymbol("llama_get_model_info", as: NativeGetModelInfo.self)
|
|
1072
|
+
+ getContextPtrFunc = loadSymbol("llama_get_context_ptr", as: NativeGetContextPtr.self)
|
|
1073
|
+
+ getLastErrorFunc = loadSymbol("llama_get_last_error", as: NativeGetLastError.self)
|
|
1074
|
+
+ freeStringFunc = loadSymbol("llama_free_string", as: NativeFreeString.self)
|
|
1075
|
+
+}
|
|
1076
|
+
+
|
|
1077
|
+
+private func nativeLastError() -> String {
|
|
1078
|
+
+ guard let pointer = getLastErrorFunc?() else {
|
|
1079
|
+
+ return "Failed to initialize native context"
|
|
1080
|
+
+ }
|
|
1081
|
+
+ let message = String(cString: pointer)
|
|
1082
|
+
+ freeStringFunc?(pointer)
|
|
1083
|
+
+ return message.isEmpty ? "Failed to initialize native context" : message
|
|
1084
|
+
+}
|
|
1085
|
+
+
|
|
1086
|
+
+private func jsonObjectFromNativeString(_ pointer: UnsafeMutablePointer<CChar>?) throws -> Any {
|
|
1087
|
+
+ guard let pointer else {
|
|
1088
|
+
+ throw LlamaError.operationFailed("Native function returned null")
|
|
1089
|
+
+ }
|
|
1090
|
+
+ let jsonText = String(cString: pointer)
|
|
1091
|
+
+ freeStringFunc?(pointer)
|
|
1092
|
+
+ guard let data = jsonText.data(using: .utf8) else {
|
|
1093
|
+
+ throw LlamaError.operationFailed("Native JSON was not valid UTF-8")
|
|
1094
|
+
+ }
|
|
1095
|
+
+ return try JSONSerialization.jsonObject(with: data)
|
|
1096
|
+
+}
|
|
1097
|
+
+
|
|
1098
|
+
+private func dictionaryFromNativeString(_ pointer: UnsafeMutablePointer<CChar>?) throws -> [String: Any] {
|
|
1099
|
+
+ let object = try jsonObjectFromNativeString(pointer)
|
|
1100
|
+
+ guard let dictionary = object as? [String: Any] else {
|
|
1101
|
+
+ throw LlamaError.operationFailed("Native JSON did not contain an object")
|
|
1102
|
+
+ }
|
|
1103
|
+
+ if let error = dictionary["error"] as? String, !error.isEmpty {
|
|
1104
|
+
+ throw LlamaError.operationFailed(error)
|
|
1105
|
+
+ }
|
|
1106
|
+
+ return dictionary
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// MARK: - Result Types
|
|
1110
|
+
@@ -56,7 +133,7 @@ enum LlamaError: Error, LocalizedError {
|
|
1111
|
+
case invalidParameters
|
|
1112
|
+
case operationFailed(String)
|
|
1113
|
+
case notImplemented
|
|
1114
|
+
-
|
|
1115
|
+
+
|
|
1116
|
+
var errorDescription: String? {
|
|
1117
|
+
switch self {
|
|
1118
|
+
case .contextNotFound:
|
|
1119
|
+
@@ -79,7 +156,7 @@ class LlamaContext {
|
|
1120
|
+
var model: LlamaModel?
|
|
1121
|
+
var isMultimodalEnabled: Bool = false
|
|
1122
|
+
var isVocoderEnabled: Bool = false
|
|
1123
|
+
-
|
|
1124
|
+
+
|
|
1125
|
+
init(id: Int) {
|
|
1126
|
+
self.id = id
|
|
1127
|
+
}
|
|
1128
|
+
@@ -93,7 +170,7 @@ class LlamaModel {
|
|
1129
|
+
let nParams: Int
|
|
1130
|
+
let chatTemplates: ChatTemplates
|
|
1131
|
+
let metadata: [String: Any]
|
|
1132
|
+
-
|
|
1133
|
+
+
|
|
1134
|
+
init(path: String, desc: String, size: Int, nEmbd: Int, nParams: Int, chatTemplates: ChatTemplates, metadata: [String: Any]) {
|
|
1135
|
+
self.path = path
|
|
1136
|
+
self.desc = desc
|
|
1137
|
+
@@ -108,7 +185,7 @@ class LlamaModel {
|
|
1138
|
+
struct ChatTemplates {
|
|
1139
|
+
let llamaChat: Bool
|
|
1140
|
+
let minja: MinjaTemplates
|
|
1141
|
+
-
|
|
1142
|
+
+
|
|
1143
|
+
init(llamaChat: Bool, minja: MinjaTemplates) {
|
|
1144
|
+
self.llamaChat = llamaChat
|
|
1145
|
+
self.minja = minja
|
|
1146
|
+
@@ -120,7 +197,7 @@ struct MinjaTemplates {
|
|
1147
|
+
let defaultCaps: MinjaCaps
|
|
1148
|
+
let toolUse: Bool
|
|
1149
|
+
let toolUseCaps: MinjaCaps
|
|
1150
|
+
-
|
|
1151
|
+
+
|
|
1152
|
+
init(default: Bool, defaultCaps: MinjaCaps, toolUse: Bool, toolUseCaps: MinjaCaps) {
|
|
1153
|
+
self.default = `default`
|
|
1154
|
+
self.defaultCaps = defaultCaps
|
|
1155
|
+
@@ -136,7 +213,7 @@ struct MinjaCaps {
|
|
1156
|
+
let systemRole: Bool
|
|
1157
|
+
let parallelToolCalls: Bool
|
|
1158
|
+
let toolCallId: Bool
|
|
1159
|
+
-
|
|
1160
|
+
+
|
|
1161
|
+
init(tools: Bool, toolCalls: Bool, toolResponses: Bool, systemRole: Bool, parallelToolCalls: Bool, toolCallId: Bool) {
|
|
1162
|
+
self.tools = tools
|
|
1163
|
+
self.toolCalls = toolCalls
|
|
1164
|
+
@@ -148,18 +225,39 @@ struct MinjaCaps {
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// MARK: - Main Implementation
|
|
1168
|
+
-@objc public class LlamaCpp: NSObject {
|
|
1169
|
+
+@objc public class LlamaCpp: NSObject, URLSessionDownloadDelegate {
|
|
1170
|
+
private var contexts: [Int: LlamaContext] = [:]
|
|
1171
|
+
private var nativeContexts: [Int64: UnsafeMutableRawPointer] = [:]
|
|
1172
|
+
private var contextIdToNative: [Int: Int64] = [:]
|
|
1173
|
+
private var contextCounter: Int = 0
|
|
1174
|
+
private var contextLimit: Int = 10
|
|
1175
|
+
private var nativeLogEnabled: Bool = false
|
|
1176
|
+
-
|
|
1177
|
+
+ private struct DownloadContext {
|
|
1178
|
+
+ let url: String
|
|
1179
|
+
+ let localURL: URL
|
|
1180
|
+
+ let completion: (LlamaResult<String>) -> Void
|
|
1181
|
+
+ var lastBytes: Int64
|
|
1182
|
+
+ var lastUpdatedAt: Date
|
|
1183
|
+
+ }
|
|
1184
|
+
+ private var downloadProgressByUrl: [String: [String: Any]] = [:]
|
|
1185
|
+
+ private var downloadTasksByUrl: [String: URLSessionDownloadTask] = [:]
|
|
1186
|
+
+ private var downloadContextsByTaskId: [Int: DownloadContext] = [:]
|
|
1187
|
+
+ private lazy var downloadSession: URLSession = {
|
|
1188
|
+
+ let configuration = URLSessionConfiguration.default
|
|
1189
|
+
+ configuration.waitsForConnectivity = true
|
|
1190
|
+
+ configuration.allowsExpensiveNetworkAccess = true
|
|
1191
|
+
+ configuration.allowsConstrainedNetworkAccess = true
|
|
1192
|
+
+ return URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
|
|
1193
|
+
+ }()
|
|
1194
|
+
+
|
|
1195
|
+
// MARK: - Core initialization and management
|
|
1196
|
+
-
|
|
1197
|
+
+
|
|
1198
|
+
func toggleNativeLog(enabled: Bool, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1199
|
+
nativeLogEnabled = enabled
|
|
1200
|
+
+ if toggleNativeLogFunc == nil {
|
|
1201
|
+
+ loadFunctionPointers()
|
|
1202
|
+
+ }
|
|
1203
|
+
+ _ = toggleNativeLogFunc?(enabled)
|
|
1204
|
+
if enabled {
|
|
1205
|
+
print("[LlamaCpp] Native logging enabled")
|
|
1206
|
+
} else {
|
|
1207
|
+
@@ -167,13 +265,13 @@ struct MinjaCaps {
|
|
1208
|
+
}
|
|
1209
|
+
completion(.success(()))
|
|
1210
|
+
}
|
|
1211
|
+
-
|
|
1212
|
+
+
|
|
1213
|
+
func setContextLimit(limit: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1214
|
+
contextLimit = limit
|
|
1215
|
+
print("[LlamaCpp] Context limit set to \(limit)")
|
|
1216
|
+
completion(.success(()))
|
|
1217
|
+
}
|
|
1218
|
+
-
|
|
1219
|
+
+
|
|
1220
|
+
func modelInfo(path: String, skip: [String], completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1221
|
+
// This would typically load model info from the GGUF file
|
|
1222
|
+
// For now, return a basic structure
|
|
1223
|
+
@@ -186,23 +284,23 @@ struct MinjaCaps {
|
|
1224
|
+
]
|
|
1225
|
+
completion(.success(modelInfo))
|
|
1226
|
+
}
|
|
1227
|
+
-
|
|
1228
|
+
+
|
|
1229
|
+
func initContext(contextId: Int, params: [String: Any], completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1230
|
+
// Check context limit
|
|
1231
|
+
if contexts.count >= contextLimit {
|
|
1232
|
+
completion(.failure(.operationFailed("Context limit reached")))
|
|
1233
|
+
return
|
|
1234
|
+
}
|
|
1235
|
+
-
|
|
1236
|
+
+
|
|
1237
|
+
// Extract parameters
|
|
1238
|
+
guard let modelPath = params["model"] as? String else {
|
|
1239
|
+
completion(.failure(.invalidParameters))
|
|
1240
|
+
return
|
|
1241
|
+
}
|
|
1242
|
+
-
|
|
1243
|
+
+
|
|
1244
|
+
// Create context
|
|
1245
|
+
let context = LlamaContext(id: contextId)
|
|
1246
|
+
-
|
|
1247
|
+
+
|
|
1248
|
+
// Create model info (this would typically load from GGUF file)
|
|
1249
|
+
let chatTemplates = ChatTemplates(
|
|
1250
|
+
llamaChat: true,
|
|
1251
|
+
@@ -227,8 +325,8 @@ struct MinjaCaps {
|
|
1252
|
+
)
|
|
1253
|
+
)
|
|
1254
|
+
)
|
|
1255
|
+
-
|
|
1256
|
+
- let model = LlamaModel(
|
|
1257
|
+
+
|
|
1258
|
+
+ var model = LlamaModel(
|
|
1259
|
+
path: modelPath,
|
|
1260
|
+
desc: "Sample model",
|
|
1261
|
+
size: 0,
|
|
1262
|
+
@@ -237,9 +335,9 @@ struct MinjaCaps {
|
|
1263
|
+
chatTemplates: chatTemplates,
|
|
1264
|
+
metadata: [:]
|
|
1265
|
+
)
|
|
1266
|
+
-
|
|
1267
|
+
+
|
|
1268
|
+
context.model = model
|
|
1269
|
+
-
|
|
1270
|
+
+
|
|
1271
|
+
// Call native initContext to create the actual C++ context
|
|
1272
|
+
// Convert params to JSON string
|
|
1273
|
+
var paramsJson = "{}"
|
|
1274
|
+
@@ -250,41 +348,64 @@ struct MinjaCaps {
|
|
1275
|
+
completion(.failure(.operationFailed("Failed to serialize params: \(error.localizedDescription)")))
|
|
1276
|
+
return
|
|
1277
|
+
}
|
|
1278
|
+
-
|
|
1279
|
+
+
|
|
1280
|
+
// Ensure function pointers are loaded
|
|
1281
|
+
if initContextFunc == nil {
|
|
1282
|
+
loadFunctionPointers()
|
|
1283
|
+
}
|
|
1284
|
+
-
|
|
1285
|
+
+
|
|
1286
|
+
// Call native function to initialize context
|
|
1287
|
+
guard let initFunc = initContextFunc else {
|
|
1288
|
+
completion(.failure(.operationFailed("Native initContext function not available")))
|
|
1289
|
+
return
|
|
1290
|
+
}
|
|
1291
|
+
-
|
|
1292
|
+
- let nativeContextId = initFunc(modelPath, paramsJson.cString(using: .utf8)!)
|
|
1293
|
+
+
|
|
1294
|
+
+ let nativeContextId = modelPath.withCString { modelCString in
|
|
1295
|
+
+ paramsJson.withCString { paramsCString in
|
|
1296
|
+
+ initFunc(modelCString, paramsCString)
|
|
1297
|
+
+ }
|
|
1298
|
+
+ }
|
|
1299
|
+
if nativeContextId > 0 {
|
|
1300
|
+
+ if let modelInfoPtr = getModelInfoFunc?(nativeContextId),
|
|
1301
|
+
+ let modelInfo = try? dictionaryFromNativeString(modelInfoPtr) {
|
|
1302
|
+
+ let numberSize = modelInfo["size"] as? NSNumber
|
|
1303
|
+
+ let numberEmbd = modelInfo["nEmbd"] as? NSNumber
|
|
1304
|
+
+ let numberParams = modelInfo["nParams"] as? NSNumber
|
|
1305
|
+
+ model = LlamaModel(
|
|
1306
|
+
+ path: modelPath,
|
|
1307
|
+
+ desc: modelInfo["desc"] as? String ?? model.desc,
|
|
1308
|
+
+ size: numberSize?.intValue ?? model.size,
|
|
1309
|
+
+ nEmbd: numberEmbd?.intValue ?? model.nEmbd,
|
|
1310
|
+
+ nParams: numberParams?.intValue ?? model.nParams,
|
|
1311
|
+
+ chatTemplates: chatTemplates,
|
|
1312
|
+
+ metadata: modelInfo["metadata"] as? [String: Any] ?? [:]
|
|
1313
|
+
+ )
|
|
1314
|
+
+ context.model = model
|
|
1315
|
+
+ }
|
|
1316
|
+
// Store the LlamaContext for Swift bookkeeping
|
|
1317
|
+
contexts[contextId] = context
|
|
1318
|
+
// Store the native context pointer and mapping for C layer
|
|
1319
|
+
- let nativePtr = UnsafeMutableRawPointer(bitPattern: Int(nativeContextId))
|
|
1320
|
+
- nativeContexts[nativeContextId] = nativePtr
|
|
1321
|
+
+ let nativePtr = getContextPtrFunc?(nativeContextId)
|
|
1322
|
+
+ if let nativePtr {
|
|
1323
|
+
+ nativeContexts[nativeContextId] = nativePtr
|
|
1324
|
+
+ }
|
|
1325
|
+
contextIdToNative[contextId] = nativeContextId
|
|
1326
|
+
-
|
|
1327
|
+
+
|
|
1328
|
+
// Register with embedding system if available
|
|
1329
|
+
- if let registerFunc = registerEmbeddingContextFunc, let ptr = nativePtr {
|
|
1330
|
+
- registerFunc(nativeContextId, ptr)
|
|
1331
|
+
+ if let registerFunc = registerEmbeddingContextFunc, let nativePtr {
|
|
1332
|
+
+ registerFunc(nativeContextId, nativePtr)
|
|
1333
|
+
}
|
|
1334
|
+
} else {
|
|
1335
|
+
- completion(.failure(.operationFailed("Failed to initialize native context")))
|
|
1336
|
+
+ completion(.failure(.operationFailed(nativeLastError())))
|
|
1337
|
+
return
|
|
1338
|
+
}
|
|
1339
|
+
-
|
|
1340
|
+
+
|
|
1341
|
+
// Return context info
|
|
1342
|
+
+ let gpuRequested = (params["no_gpu_devices"] as? Bool) != true && ((params["n_gpu_layers"] as? Int) ?? 0) != 0
|
|
1343
|
+
let contextInfo: [String: Any] = [
|
|
1344
|
+
"contextId": contextId,
|
|
1345
|
+
- "gpu": false,
|
|
1346
|
+
- "reasonNoGPU": "Not implemented",
|
|
1347
|
+
+ "gpu": gpuRequested,
|
|
1348
|
+
+ "reasonNoGPU": gpuRequested ? "" : "GPU disabled by load options",
|
|
1349
|
+
"model": [
|
|
1350
|
+
"desc": model.desc,
|
|
1351
|
+
"size": model.size,
|
|
1352
|
+
@@ -317,34 +438,34 @@ struct MinjaCaps {
|
|
1353
|
+
"isChatTemplateSupported": true
|
|
1354
|
+
]
|
|
1355
|
+
]
|
|
1356
|
+
-
|
|
1357
|
+
+
|
|
1358
|
+
completion(.success(contextInfo))
|
|
1359
|
+
}
|
|
1360
|
+
-
|
|
1361
|
+
+
|
|
1362
|
+
func releaseContext(contextId: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1363
|
+
guard contexts[contextId] != nil else {
|
|
1364
|
+
completion(.failure(.contextNotFound))
|
|
1365
|
+
return
|
|
1366
|
+
}
|
|
1367
|
+
-
|
|
1368
|
+
+
|
|
1369
|
+
let nativeId = contextIdToNative[contextId] ?? Int64(contextId)
|
|
1370
|
+
-
|
|
1371
|
+
+
|
|
1372
|
+
// Unregister from embedding system if available
|
|
1373
|
+
if let unregisterFunc = unregisterEmbeddingContextFunc {
|
|
1374
|
+
unregisterFunc(nativeId)
|
|
1375
|
+
}
|
|
1376
|
+
-
|
|
1377
|
+
+
|
|
1378
|
+
// Call native release function
|
|
1379
|
+
if let releaseFunc = releaseContextFunc {
|
|
1380
|
+
releaseFunc(nativeId)
|
|
1381
|
+
}
|
|
1382
|
+
-
|
|
1383
|
+
+
|
|
1384
|
+
contexts.removeValue(forKey: contextId)
|
|
1385
|
+
nativeContexts.removeValue(forKey: nativeId)
|
|
1386
|
+
contextIdToNative.removeValue(forKey: contextId)
|
|
1387
|
+
completion(.success(()))
|
|
1388
|
+
}
|
|
1389
|
+
-
|
|
1390
|
+
+
|
|
1391
|
+
func releaseAllContexts(completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1392
|
+
// Unregister all contexts from embedding system
|
|
1393
|
+
if let unregisterFunc = unregisterEmbeddingContextFunc {
|
|
1394
|
+
@@ -352,95 +473,122 @@ struct MinjaCaps {
|
|
1395
|
+
unregisterFunc(nativeId)
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
-
|
|
1399
|
+
+ if let releaseFunc = releaseContextFunc {
|
|
1400
|
+
+ for (_, nativeId) in contextIdToNative {
|
|
1401
|
+
+ releaseFunc(nativeId)
|
|
1402
|
+
+ }
|
|
1403
|
+
+ }
|
|
1404
|
+
+
|
|
1405
|
+
contexts.removeAll()
|
|
1406
|
+
nativeContexts.removeAll()
|
|
1407
|
+
contextIdToNative.removeAll()
|
|
1408
|
+
completion(.success(()))
|
|
1409
|
+
}
|
|
1410
|
+
-
|
|
1411
|
+
+
|
|
1412
|
+
// MARK: - Chat and completion
|
|
1413
|
+
-
|
|
1414
|
+
+
|
|
1415
|
+
func getFormattedChat(contextId: Int, messages: String, chatTemplate: String?, params: [String: Any]?, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1416
|
+
- guard let context = contexts[contextId] else {
|
|
1417
|
+
+ guard contexts[contextId] != nil else {
|
|
1418
|
+
completion(.failure(.contextNotFound))
|
|
1419
|
+
return
|
|
1420
|
+
}
|
|
1421
|
+
-
|
|
1422
|
+
- // This would typically format the chat using the model's chat templates
|
|
1423
|
+
- // For now, return a basic formatted chat
|
|
1424
|
+
- let formattedChat: [String: Any] = [
|
|
1425
|
+
- "type": "llama-chat",
|
|
1426
|
+
- "prompt": messages,
|
|
1427
|
+
- "has_media": false,
|
|
1428
|
+
- "media_paths": []
|
|
1429
|
+
- ]
|
|
1430
|
+
-
|
|
1431
|
+
- completion(.success(formattedChat))
|
|
1432
|
+
+ if getFormattedChatFunc == nil {
|
|
1433
|
+
+ loadFunctionPointers()
|
|
1434
|
+
+ }
|
|
1435
|
+
+ guard let nativeId = contextIdToNative[contextId],
|
|
1436
|
+
+ let formatFunc = getFormattedChatFunc else {
|
|
1437
|
+
+ completion(.failure(.operationFailed("Native getFormattedChat function not available")))
|
|
1438
|
+
+ return
|
|
1439
|
+
+ }
|
|
1440
|
+
+ let template = chatTemplate ?? ""
|
|
1441
|
+
+ do {
|
|
1442
|
+
+ let formatted = try messages.withCString { messagesCString in
|
|
1443
|
+
+ try template.withCString { templateCString in
|
|
1444
|
+
+ let ptr = formatFunc(nativeId, messagesCString, templateCString)
|
|
1445
|
+
+ let object = try jsonObjectFromNativeString(ptr)
|
|
1446
|
+
+ return object as? String ?? messages
|
|
1447
|
+
+ }
|
|
1448
|
+
+ }
|
|
1449
|
+
+ let formattedChat: [String: Any] = [
|
|
1450
|
+
+ "type": "llama-chat",
|
|
1451
|
+
+ "prompt": formatted,
|
|
1452
|
+
+ "has_media": false,
|
|
1453
|
+
+ "media_paths": []
|
|
1454
|
+
+ ]
|
|
1455
|
+
+ completion(.success(formattedChat))
|
|
1456
|
+
+ } catch let error as LlamaError {
|
|
1457
|
+
+ completion(.failure(error))
|
|
1458
|
+
+ } catch {
|
|
1459
|
+
+ completion(.failure(.operationFailed(error.localizedDescription)))
|
|
1460
|
+
+ }
|
|
1461
|
+
}
|
|
1462
|
+
-
|
|
1463
|
+
+
|
|
1464
|
+
func completion(contextId: Int, params: [String: Any], completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1465
|
+
- guard let context = contexts[contextId] else {
|
|
1466
|
+
+ guard contexts[contextId] != nil else {
|
|
1467
|
+
completion(.failure(.contextNotFound))
|
|
1468
|
+
return
|
|
1469
|
+
}
|
|
1470
|
+
-
|
|
1471
|
+
- // This would typically perform the completion using llama.cpp
|
|
1472
|
+
- // For now, return a basic completion result
|
|
1473
|
+
- let completionResult: [String: Any] = [
|
|
1474
|
+
- "text": "Sample completion text",
|
|
1475
|
+
- "reasoning_content": "",
|
|
1476
|
+
- "tool_calls": [],
|
|
1477
|
+
- "content": "Sample completion text",
|
|
1478
|
+
- "chat_format": 0,
|
|
1479
|
+
- "tokens_predicted": 0,
|
|
1480
|
+
- "tokens_evaluated": 0,
|
|
1481
|
+
- "truncated": false,
|
|
1482
|
+
- "stopped_eos": false,
|
|
1483
|
+
- "stopped_word": "",
|
|
1484
|
+
- "stopped_limit": 0,
|
|
1485
|
+
- "stopping_word": "",
|
|
1486
|
+
- "context_full": false,
|
|
1487
|
+
- "interrupted": false,
|
|
1488
|
+
- "tokens_cached": 0,
|
|
1489
|
+
- "timings": [
|
|
1490
|
+
- "prompt_n": 0,
|
|
1491
|
+
- "prompt_ms": 0,
|
|
1492
|
+
- "prompt_per_token_ms": 0,
|
|
1493
|
+
- "prompt_per_second": 0,
|
|
1494
|
+
- "predicted_n": 0,
|
|
1495
|
+
- "predicted_ms": 0,
|
|
1496
|
+
- "predicted_per_token_ms": 0,
|
|
1497
|
+
- "predicted_per_second": 0
|
|
1498
|
+
- ]
|
|
1499
|
+
- ]
|
|
1500
|
+
-
|
|
1501
|
+
- completion(.success(completionResult))
|
|
1502
|
+
+ if completionFunc == nil {
|
|
1503
|
+
+ loadFunctionPointers()
|
|
1504
|
+
+ }
|
|
1505
|
+
+ guard let nativeId = contextIdToNative[contextId],
|
|
1506
|
+
+ let completionFunc else {
|
|
1507
|
+
+ completion(.failure(.operationFailed("Native completion function not available")))
|
|
1508
|
+
+ return
|
|
1509
|
+
+ }
|
|
1510
|
+
+ guard let prompt = params["prompt"] as? String, !prompt.isEmpty else {
|
|
1511
|
+
+ completion(.failure(.invalidParameters))
|
|
1512
|
+
+ return
|
|
1513
|
+
+ }
|
|
1514
|
+
+ var paramsJson = "{}"
|
|
1515
|
+
+ do {
|
|
1516
|
+
+ let paramsData = try JSONSerialization.data(withJSONObject: params)
|
|
1517
|
+
+ paramsJson = String(data: paramsData, encoding: .utf8) ?? "{}"
|
|
1518
|
+
+ } catch {
|
|
1519
|
+
+ completion(.failure(.operationFailed("Failed to serialize params: \(error.localizedDescription)")))
|
|
1520
|
+
+ return
|
|
1521
|
+
+ }
|
|
1522
|
+
+ do {
|
|
1523
|
+
+ let result = try prompt.withCString { promptCString in
|
|
1524
|
+
+ try paramsJson.withCString { paramsCString in
|
|
1525
|
+
+ try dictionaryFromNativeString(completionFunc(nativeId, promptCString, paramsCString))
|
|
1526
|
+
+ }
|
|
1527
|
+
+ }
|
|
1528
|
+
+ completion(.success(result))
|
|
1529
|
+
+ } catch let error as LlamaError {
|
|
1530
|
+
+ completion(.failure(error))
|
|
1531
|
+
+ } catch {
|
|
1532
|
+
+ completion(.failure(.operationFailed(error.localizedDescription)))
|
|
1533
|
+
+ }
|
|
1534
|
+
}
|
|
1535
|
+
-
|
|
1536
|
+
+
|
|
1537
|
+
func stopCompletion(contextId: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1538
|
+
guard contexts[contextId] != nil else {
|
|
1539
|
+
completion(.failure(.contextNotFound))
|
|
1540
|
+
return
|
|
1541
|
+
}
|
|
1542
|
+
-
|
|
1543
|
+
- // This would typically stop any ongoing completion
|
|
1544
|
+
+
|
|
1545
|
+
+ if stopCompletionFunc == nil {
|
|
1546
|
+
+ loadFunctionPointers()
|
|
1547
|
+
+ }
|
|
1548
|
+
+ let nativeId = contextIdToNative[contextId] ?? Int64(contextId)
|
|
1549
|
+
+ stopCompletionFunc?(nativeId)
|
|
1550
|
+
completion(.success(()))
|
|
1551
|
+
}
|
|
1552
|
+
-
|
|
1553
|
+
+
|
|
1554
|
+
// MARK: - Chat-first methods (like llama-cli -sys)
|
|
1555
|
+
-
|
|
1556
|
+
+
|
|
1557
|
+
func chat(contextId: Int, messages: [JSObject], system: String?, chatTemplate: String?, params: [String: Any]?, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1558
|
+
guard contexts[contextId] != nil else {
|
|
1559
|
+
completion(.failure(.contextNotFound))
|
|
1560
|
+
return
|
|
1561
|
+
}
|
|
1562
|
+
-
|
|
1563
|
+
+
|
|
1564
|
+
do {
|
|
1565
|
+
// Convert JSObject messages to JSON string
|
|
1566
|
+
let messagesData = try JSONSerialization.data(withJSONObject: messages)
|
|
1567
|
+
let messagesJson = String(data: messagesData, encoding: .utf8) ?? "[]"
|
|
1568
|
+
-
|
|
1569
|
+
+
|
|
1570
|
+
// Add system message if provided
|
|
1571
|
+
var allMessages = messages
|
|
1572
|
+
if let system = system, !system.isEmpty {
|
|
1573
|
+
@@ -451,35 +599,35 @@ struct MinjaCaps {
|
|
1574
|
+
let jsSystem = JSTypes.coerceDictionaryToJSObject(systemMessage) ?? [:]
|
|
1575
|
+
allMessages.insert(jsSystem, at: 0)
|
|
1576
|
+
}
|
|
1577
|
+
-
|
|
1578
|
+
+
|
|
1579
|
+
// Convert to JSON string for getFormattedChat
|
|
1580
|
+
let allMessagesData = try JSONSerialization.data(withJSONObject: allMessages)
|
|
1581
|
+
let allMessagesJson = String(data: allMessagesData, encoding: .utf8) ?? "[]"
|
|
1582
|
+
-
|
|
1583
|
+
+
|
|
1584
|
+
// First, format the chat
|
|
1585
|
+
getFormattedChat(contextId: contextId, messages: allMessagesJson, chatTemplate: chatTemplate, params: nil) { [weak self] result in
|
|
1586
|
+
switch result {
|
|
1587
|
+
case .success(let formattedResult):
|
|
1588
|
+
// Extract the formatted prompt
|
|
1589
|
+
let formattedPrompt = formattedResult["prompt"] as? String ?? ""
|
|
1590
|
+
-
|
|
1591
|
+
+
|
|
1592
|
+
// Create completion parameters
|
|
1593
|
+
var completionParams = params ?? [:]
|
|
1594
|
+
completionParams["prompt"] = formattedPrompt
|
|
1595
|
+
-
|
|
1596
|
+
+
|
|
1597
|
+
// Call completion with formatted prompt
|
|
1598
|
+
self?.completion(contextId: contextId, params: completionParams, completion: completion)
|
|
1599
|
+
-
|
|
1600
|
+
+
|
|
1601
|
+
case .failure(let error):
|
|
1602
|
+
completion(.failure(error))
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
-
|
|
1606
|
+
+
|
|
1607
|
+
} catch {
|
|
1608
|
+
completion(.failure(.contextNotFound)) // Use a more appropriate error
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
-
|
|
1612
|
+
+
|
|
1613
|
+
func chatWithSystem(contextId: Int, system: String, message: String, params: [String: Any]?, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1614
|
+
// Create a simple message array
|
|
1615
|
+
let userMessage: [String: Any] = [
|
|
1616
|
+
@@ -488,60 +636,60 @@ struct MinjaCaps {
|
|
1617
|
+
]
|
|
1618
|
+
let jsUser = JSTypes.coerceDictionaryToJSObject(userMessage) ?? [:]
|
|
1619
|
+
let messages: [JSObject] = [jsUser]
|
|
1620
|
+
-
|
|
1621
|
+
+
|
|
1622
|
+
// Call the main chat method
|
|
1623
|
+
chat(contextId: contextId, messages: messages, system: system, chatTemplate: nil, params: params, completion: completion)
|
|
1624
|
+
}
|
|
1625
|
+
-
|
|
1626
|
+
+
|
|
1627
|
+
func generateText(contextId: Int, prompt: String, params: [String: Any]?, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1628
|
+
guard contexts[contextId] != nil else {
|
|
1629
|
+
completion(.failure(.contextNotFound))
|
|
1630
|
+
return
|
|
1631
|
+
}
|
|
1632
|
+
-
|
|
1633
|
+
+
|
|
1634
|
+
// Create completion parameters
|
|
1635
|
+
var completionParams = params ?? [:]
|
|
1636
|
+
completionParams["prompt"] = prompt
|
|
1637
|
+
-
|
|
1638
|
+
+
|
|
1639
|
+
// Call completion method directly
|
|
1640
|
+
self.completion(contextId: contextId, params: completionParams, completion: completion)
|
|
1641
|
+
}
|
|
1642
|
+
-
|
|
1643
|
+
+
|
|
1644
|
+
// MARK: - Session management
|
|
1645
|
+
-
|
|
1646
|
+
+
|
|
1647
|
+
func loadSession(contextId: Int, filepath: String, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1648
|
+
guard contexts[contextId] != nil else {
|
|
1649
|
+
completion(.failure(.contextNotFound))
|
|
1650
|
+
return
|
|
1651
|
+
}
|
|
1652
|
+
-
|
|
1653
|
+
+
|
|
1654
|
+
// This would typically load session from file
|
|
1655
|
+
let sessionResult: [String: Any] = [
|
|
1656
|
+
"tokens_loaded": 0,
|
|
1657
|
+
"prompt": ""
|
|
1658
|
+
]
|
|
1659
|
+
-
|
|
1660
|
+
+
|
|
1661
|
+
completion(.success(sessionResult))
|
|
1662
|
+
}
|
|
1663
|
+
-
|
|
1664
|
+
+
|
|
1665
|
+
func saveSession(contextId: Int, filepath: String, size: Int, completion: @escaping (LlamaResult<Int>) -> Void) {
|
|
1666
|
+
guard contexts[contextId] != nil else {
|
|
1667
|
+
completion(.failure(.contextNotFound))
|
|
1668
|
+
return
|
|
1669
|
+
}
|
|
1670
|
+
-
|
|
1671
|
+
+
|
|
1672
|
+
// This would typically save session to file
|
|
1673
|
+
completion(.success(0))
|
|
1674
|
+
}
|
|
1675
|
+
-
|
|
1676
|
+
+
|
|
1677
|
+
// MARK: - Tokenization
|
|
1678
|
+
-
|
|
1679
|
+
+
|
|
1680
|
+
func tokenize(contextId: Int, text: String, imagePaths: [String], completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1681
|
+
guard contexts[contextId] != nil else {
|
|
1682
|
+
completion(.failure(.contextNotFound))
|
|
1683
|
+
return
|
|
1684
|
+
}
|
|
1685
|
+
-
|
|
1686
|
+
+
|
|
1687
|
+
// This would typically tokenize the text using the model's tokenizer
|
|
1688
|
+
let tokenizeResult: [String: Any] = [
|
|
1689
|
+
"tokens": [],
|
|
1690
|
+
@@ -550,33 +698,33 @@ struct MinjaCaps {
|
|
1691
|
+
"chunk_pos": [],
|
|
1692
|
+
"chunk_pos_images": []
|
|
1693
|
+
]
|
|
1694
|
+
-
|
|
1695
|
+
+
|
|
1696
|
+
completion(.success(tokenizeResult))
|
|
1697
|
+
}
|
|
1698
|
+
-
|
|
1699
|
+
+
|
|
1700
|
+
func detokenize(contextId: Int, tokens: [Int], completion: @escaping (LlamaResult<String>) -> Void) {
|
|
1701
|
+
guard contexts[contextId] != nil else {
|
|
1702
|
+
completion(.failure(.contextNotFound))
|
|
1703
|
+
return
|
|
1704
|
+
}
|
|
1705
|
+
-
|
|
1706
|
+
+
|
|
1707
|
+
// This would typically detokenize using the model's tokenizer
|
|
1708
|
+
completion(.success(""))
|
|
1709
|
+
}
|
|
1710
|
+
-
|
|
1711
|
+
+
|
|
1712
|
+
// MARK: - Embeddings and reranking
|
|
1713
|
+
-
|
|
1714
|
+
+
|
|
1715
|
+
func embedding(contextId: Int, text: String, params: [String: Any], completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1716
|
+
guard let context = contexts[contextId] else {
|
|
1717
|
+
completion(.failure(.contextNotFound))
|
|
1718
|
+
return
|
|
1719
|
+
}
|
|
1720
|
+
-
|
|
1721
|
+
+
|
|
1722
|
+
// Ensure function pointers are loaded
|
|
1723
|
+
if embeddingFunc == nil {
|
|
1724
|
+
loadFunctionPointers()
|
|
1725
|
+
}
|
|
1726
|
+
-
|
|
1727
|
+
+
|
|
1728
|
+
// Check if native embedding function is available
|
|
1729
|
+
guard let embeddingFunction = embeddingFunc else {
|
|
1730
|
+
// Native function not available - this means the C++ layer needs to implement it
|
|
1731
|
+
@@ -585,13 +733,13 @@ struct MinjaCaps {
|
|
1732
|
+
completion(.failure(.notImplemented))
|
|
1733
|
+
return
|
|
1734
|
+
}
|
|
1735
|
+
-
|
|
1736
|
+
+
|
|
1737
|
+
// Get embedding dimension from model
|
|
1738
|
+
guard let nEmbd = context.model?.nEmbd, nEmbd > 0 else {
|
|
1739
|
+
completion(.failure(.operationFailed("Model embedding dimension (n_embd) not available. Model may not be loaded or may not support embeddings.")))
|
|
1740
|
+
return
|
|
1741
|
+
}
|
|
1742
|
+
-
|
|
1743
|
+
+
|
|
1744
|
+
// Convert params to JSON string for native call
|
|
1745
|
+
var paramsJson = "{}"
|
|
1746
|
+
if !params.isEmpty {
|
|
1747
|
+
@@ -602,249 +750,256 @@ struct MinjaCaps {
|
|
1748
|
+
print("Error serializing params: \(error)")
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
-
|
|
1752
|
+
- // Call native embedding function
|
|
1753
|
+
- let paramsCString = paramsJson.cString(using: .utf8)
|
|
1754
|
+
- guard let baseAddress = paramsCString else {
|
|
1755
|
+
- completion(.failure(.operationFailed("Failed to convert params to C string")))
|
|
1756
|
+
- return
|
|
1757
|
+
+
|
|
1758
|
+
+ let nativeId = contextIdToNative[contextId] ?? Int64(contextId)
|
|
1759
|
+
+ let embeddingPtr = text.withCString { textCString in
|
|
1760
|
+
+ paramsJson.withCString { paramsCString in
|
|
1761
|
+
+ embeddingFunction(nativeId, textCString, paramsCString)
|
|
1762
|
+
+ }
|
|
1763
|
+
}
|
|
1764
|
+
-
|
|
1765
|
+
- // Get embedding vector from native layer
|
|
1766
|
+
- // Note: The native function signature should be:
|
|
1767
|
+
- // UnsafePointer<Float>? llama_embedding(Int64 contextId, String text, UnsafePointer<Int8> params)
|
|
1768
|
+
- // The returned pointer should point to an array of nEmbd floats
|
|
1769
|
+
- if let embeddingPtr = embeddingFunction(Int64(contextId), text, baseAddress) {
|
|
1770
|
+
+ if let embeddingPtr {
|
|
1771
|
+
// Convert C array to Swift array
|
|
1772
|
+
let embeddingArray = Array(UnsafeBufferPointer(start: embeddingPtr, count: nEmbd))
|
|
1773
|
+
-
|
|
1774
|
+
+
|
|
1775
|
+
// Convert Float array to Double array for JSON compatibility
|
|
1776
|
+
let embeddingDoubles = embeddingArray.map { Double($0) }
|
|
1777
|
+
-
|
|
1778
|
+
+
|
|
1779
|
+
let embeddingResult: [String: Any] = [
|
|
1780
|
+
"embedding": embeddingDoubles,
|
|
1781
|
+
"n_embd": nEmbd
|
|
1782
|
+
]
|
|
1783
|
+
-
|
|
1784
|
+
+
|
|
1785
|
+
completion(.success(embeddingResult))
|
|
1786
|
+
} else {
|
|
1787
|
+
completion(.failure(.operationFailed("Native embedding function returned null. Check native C++ implementation.")))
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
-
|
|
1791
|
+
+
|
|
1792
|
+
func rerank(contextId: Int, query: String, documents: [String], params: [String: Any]?, completion: @escaping (LlamaResult<[[String: Any]]>) -> Void) {
|
|
1793
|
+
guard contexts[contextId] != nil else {
|
|
1794
|
+
completion(.failure(.contextNotFound))
|
|
1795
|
+
return
|
|
1796
|
+
}
|
|
1797
|
+
-
|
|
1798
|
+
+
|
|
1799
|
+
// This would typically perform reranking
|
|
1800
|
+
let rerankResults: [[String: Any]] = []
|
|
1801
|
+
completion(.success(rerankResults))
|
|
1802
|
+
}
|
|
1803
|
+
-
|
|
1804
|
+
+
|
|
1805
|
+
// MARK: - Benchmarking
|
|
1806
|
+
-
|
|
1807
|
+
+
|
|
1808
|
+
func bench(contextId: Int, pp: Int, tg: Int, pl: Int, nr: Int, completion: @escaping (LlamaResult<String>) -> Void) {
|
|
1809
|
+
guard contexts[contextId] != nil else {
|
|
1810
|
+
completion(.failure(.contextNotFound))
|
|
1811
|
+
return
|
|
1812
|
+
}
|
|
1813
|
+
-
|
|
1814
|
+
+
|
|
1815
|
+
// This would typically run benchmarks
|
|
1816
|
+
let benchResult = "[]"
|
|
1817
|
+
completion(.success(benchResult))
|
|
1818
|
+
}
|
|
1819
|
+
-
|
|
1820
|
+
+
|
|
1821
|
+
// MARK: - LoRA adapters
|
|
1822
|
+
-
|
|
1823
|
+
+
|
|
1824
|
+
func applyLoraAdapters(contextId: Int, loraAdapters: [[String: Any]], completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1825
|
+
guard contexts[contextId] != nil else {
|
|
1826
|
+
completion(.failure(.contextNotFound))
|
|
1827
|
+
return
|
|
1828
|
+
}
|
|
1829
|
+
-
|
|
1830
|
+
+
|
|
1831
|
+
// This would typically apply LoRA adapters
|
|
1832
|
+
completion(.success(()))
|
|
1833
|
+
}
|
|
1834
|
+
-
|
|
1835
|
+
+
|
|
1836
|
+
func removeLoraAdapters(contextId: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1837
|
+
guard contexts[contextId] != nil else {
|
|
1838
|
+
completion(.failure(.contextNotFound))
|
|
1839
|
+
return
|
|
1840
|
+
}
|
|
1841
|
+
-
|
|
1842
|
+
+
|
|
1843
|
+
// This would typically remove LoRA adapters
|
|
1844
|
+
completion(.success(()))
|
|
1845
|
+
}
|
|
1846
|
+
-
|
|
1847
|
+
+
|
|
1848
|
+
func getLoadedLoraAdapters(contextId: Int, completion: @escaping (LlamaResult<[[String: Any]]>) -> Void) {
|
|
1849
|
+
guard contexts[contextId] != nil else {
|
|
1850
|
+
completion(.failure(.contextNotFound))
|
|
1851
|
+
return
|
|
1852
|
+
}
|
|
1853
|
+
-
|
|
1854
|
+
+
|
|
1855
|
+
// This would typically return loaded LoRA adapters
|
|
1856
|
+
let adapters: [[String: Any]] = []
|
|
1857
|
+
completion(.success(adapters))
|
|
1858
|
+
}
|
|
1859
|
+
-
|
|
1860
|
+
+
|
|
1861
|
+
// MARK: - Multimodal methods
|
|
1862
|
+
-
|
|
1863
|
+
+
|
|
1864
|
+
func initMultimodal(contextId: Int, path: String, useGpu: Bool, completion: @escaping (LlamaResult<Bool>) -> Void) {
|
|
1865
|
+
guard let context = contexts[contextId] else {
|
|
1866
|
+
completion(.failure(.contextNotFound))
|
|
1867
|
+
return
|
|
1868
|
+
}
|
|
1869
|
+
-
|
|
1870
|
+
+
|
|
1871
|
+
context.isMultimodalEnabled = true
|
|
1872
|
+
completion(.success(true))
|
|
1873
|
+
}
|
|
1874
|
+
-
|
|
1875
|
+
+
|
|
1876
|
+
func isMultimodalEnabled(contextId: Int, completion: @escaping (LlamaResult<Bool>) -> Void) {
|
|
1877
|
+
guard let context = contexts[contextId] else {
|
|
1878
|
+
completion(.failure(.contextNotFound))
|
|
1879
|
+
return
|
|
1880
|
+
}
|
|
1881
|
+
-
|
|
1882
|
+
+
|
|
1883
|
+
completion(.success(context.isMultimodalEnabled))
|
|
1884
|
+
}
|
|
1885
|
+
-
|
|
1886
|
+
+
|
|
1887
|
+
func getMultimodalSupport(contextId: Int, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1888
|
+
guard contexts[contextId] != nil else {
|
|
1889
|
+
completion(.failure(.contextNotFound))
|
|
1890
|
+
return
|
|
1891
|
+
}
|
|
1892
|
+
-
|
|
1893
|
+
+
|
|
1894
|
+
let support: [String: Any] = [
|
|
1895
|
+
"vision": true,
|
|
1896
|
+
"audio": true
|
|
1897
|
+
]
|
|
1898
|
+
-
|
|
1899
|
+
+
|
|
1900
|
+
completion(.success(support))
|
|
1901
|
+
}
|
|
1902
|
+
-
|
|
1903
|
+
+
|
|
1904
|
+
func releaseMultimodal(contextId: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1905
|
+
guard let context = contexts[contextId] else {
|
|
1906
|
+
completion(.failure(.contextNotFound))
|
|
1907
|
+
return
|
|
1908
|
+
}
|
|
1909
|
+
-
|
|
1910
|
+
+
|
|
1911
|
+
context.isMultimodalEnabled = false
|
|
1912
|
+
completion(.success(()))
|
|
1913
|
+
}
|
|
1914
|
+
-
|
|
1915
|
+
+
|
|
1916
|
+
// MARK: - TTS methods
|
|
1917
|
+
-
|
|
1918
|
+
+
|
|
1919
|
+
func initVocoder(contextId: Int, path: String, nBatch: Int?, completion: @escaping (LlamaResult<Bool>) -> Void) {
|
|
1920
|
+
guard let context = contexts[contextId] else {
|
|
1921
|
+
completion(.failure(.contextNotFound))
|
|
1922
|
+
return
|
|
1923
|
+
}
|
|
1924
|
+
-
|
|
1925
|
+
+
|
|
1926
|
+
context.isVocoderEnabled = true
|
|
1927
|
+
completion(.success(true))
|
|
1928
|
+
}
|
|
1929
|
+
-
|
|
1930
|
+
+
|
|
1931
|
+
func isVocoderEnabled(contextId: Int, completion: @escaping (LlamaResult<Bool>) -> Void) {
|
|
1932
|
+
guard let context = contexts[contextId] else {
|
|
1933
|
+
completion(.failure(.contextNotFound))
|
|
1934
|
+
return
|
|
1935
|
+
}
|
|
1936
|
+
-
|
|
1937
|
+
+
|
|
1938
|
+
completion(.success(context.isVocoderEnabled))
|
|
1939
|
+
}
|
|
1940
|
+
-
|
|
1941
|
+
+
|
|
1942
|
+
func getFormattedAudioCompletion(contextId: Int, speakerJsonStr: String, textToSpeak: String, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
1943
|
+
guard contexts[contextId] != nil else {
|
|
1944
|
+
completion(.failure(.contextNotFound))
|
|
1945
|
+
return
|
|
1946
|
+
}
|
|
1947
|
+
-
|
|
1948
|
+
+
|
|
1949
|
+
let audioCompletion: [String: Any] = [
|
|
1950
|
+
"prompt": "",
|
|
1951
|
+
"grammar": NSNull()
|
|
1952
|
+
]
|
|
1953
|
+
-
|
|
1954
|
+
+
|
|
1955
|
+
completion(.success(audioCompletion))
|
|
1956
|
+
}
|
|
1957
|
+
-
|
|
1958
|
+
+
|
|
1959
|
+
func getAudioCompletionGuideTokens(contextId: Int, textToSpeak: String, completion: @escaping (LlamaResult<[Int]>) -> Void) {
|
|
1960
|
+
guard contexts[contextId] != nil else {
|
|
1961
|
+
completion(.failure(.contextNotFound))
|
|
1962
|
+
return
|
|
1963
|
+
}
|
|
1964
|
+
-
|
|
1965
|
+
+
|
|
1966
|
+
let tokens: [Int] = []
|
|
1967
|
+
completion(.success(tokens))
|
|
1968
|
+
}
|
|
1969
|
+
-
|
|
1970
|
+
+
|
|
1971
|
+
func decodeAudioTokens(contextId: Int, tokens: [Int], completion: @escaping (LlamaResult<[Int]>) -> Void) {
|
|
1972
|
+
guard contexts[contextId] != nil else {
|
|
1973
|
+
completion(.failure(.contextNotFound))
|
|
1974
|
+
return
|
|
1975
|
+
}
|
|
1976
|
+
-
|
|
1977
|
+
+
|
|
1978
|
+
let decodedTokens: [Int] = []
|
|
1979
|
+
completion(.success(decodedTokens))
|
|
1980
|
+
}
|
|
1981
|
+
-
|
|
1982
|
+
+
|
|
1983
|
+
func releaseVocoder(contextId: Int, completion: @escaping (LlamaResult<Void>) -> Void) {
|
|
1984
|
+
guard let context = contexts[contextId] else {
|
|
1985
|
+
completion(.failure(.contextNotFound))
|
|
1986
|
+
return
|
|
1987
|
+
}
|
|
1988
|
+
-
|
|
1989
|
+
+
|
|
1990
|
+
context.isVocoderEnabled = false
|
|
1991
|
+
completion(.success(()))
|
|
1992
|
+
}
|
|
1993
|
+
-
|
|
1994
|
+
+
|
|
1995
|
+
// MARK: - Model download and management
|
|
1996
|
+
-
|
|
1997
|
+
+
|
|
1998
|
+
func downloadModel(url: String, filename: String, completion: @escaping (LlamaResult<String>) -> Void) {
|
|
1999
|
+
- // Get the documents directory
|
|
2000
|
+
let fileManager = FileManager.default
|
|
2001
|
+
guard let documentsDir = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first else {
|
|
2002
|
+
completion(.failure(.operationFailed("Could not access documents directory")))
|
|
2003
|
+
return
|
|
2004
|
+
}
|
|
2005
|
+
-
|
|
2006
|
+
+
|
|
2007
|
+
let localPath = documentsDir.appendingPathComponent(filename).path
|
|
2008
|
+
-
|
|
2009
|
+
+
|
|
2010
|
+
// Check if file already exists
|
|
2011
|
+
if fileManager.fileExists(atPath: localPath) {
|
|
2012
|
+
completion(.success(localPath))
|
|
2013
|
+
return
|
|
2014
|
+
}
|
|
2015
|
+
-
|
|
2016
|
+
- // Download the file asynchronously
|
|
2017
|
+
- DispatchQueue.global(qos: .background).async {
|
|
2018
|
+
- guard let downloadURL = URL(string: url) else {
|
|
2019
|
+
- DispatchQueue.main.async {
|
|
2020
|
+
- completion(.failure(.operationFailed("Invalid URL")))
|
|
2021
|
+
- }
|
|
2022
|
+
- return
|
|
2023
|
+
- }
|
|
2024
|
+
-
|
|
2025
|
+
- do {
|
|
2026
|
+
- let data = try Data(contentsOf: downloadURL)
|
|
2027
|
+
- try data.write(to: URL(fileURLWithPath: localPath))
|
|
2028
|
+
-
|
|
2029
|
+
- DispatchQueue.main.async {
|
|
2030
|
+
- completion(.success(localPath))
|
|
2031
|
+
- }
|
|
2032
|
+
- } catch {
|
|
2033
|
+
- DispatchQueue.main.async {
|
|
2034
|
+
- completion(.failure(.operationFailed("Download failed: \(error.localizedDescription)")))
|
|
2035
|
+
- }
|
|
2036
|
+
- }
|
|
2037
|
+
+
|
|
2038
|
+
+ guard let downloadURL = URL(string: url) else {
|
|
2039
|
+
+ completion(.failure(.operationFailed("Invalid URL")))
|
|
2040
|
+
+ return
|
|
2041
|
+
+ }
|
|
2042
|
+
+
|
|
2043
|
+
+ if let existing = downloadTasksByUrl[url] {
|
|
2044
|
+
+ downloadProgressByUrl[url] = [
|
|
2045
|
+
+ "url": url,
|
|
2046
|
+
+ "downloaded": existing.countOfBytesReceived,
|
|
2047
|
+
+ "total": existing.countOfBytesExpectedToReceive,
|
|
2048
|
+
+ "percentage": existing.countOfBytesExpectedToReceive > 0
|
|
2049
|
+
+ ? Double(existing.countOfBytesReceived) / Double(existing.countOfBytesExpectedToReceive) * 100.0
|
|
2050
|
+
+ : 0.0,
|
|
2051
|
+
+ "bytesPerSec": 0.0,
|
|
2052
|
+
+ "etaMs": NSNull()
|
|
2053
|
+
+ ]
|
|
2054
|
+
+ return
|
|
2055
|
+
}
|
|
2056
|
+
+
|
|
2057
|
+
+ let task = downloadSession.downloadTask(with: downloadURL)
|
|
2058
|
+
+ downloadTasksByUrl[url] = task
|
|
2059
|
+
+ downloadContextsByTaskId[task.taskIdentifier] = DownloadContext(
|
|
2060
|
+
+ url: url,
|
|
2061
|
+
+ localURL: URL(fileURLWithPath: localPath),
|
|
2062
|
+
+ completion: completion,
|
|
2063
|
+
+ lastBytes: 0,
|
|
2064
|
+
+ lastUpdatedAt: Date()
|
|
2065
|
+
+ )
|
|
2066
|
+
+ downloadProgressByUrl[url] = [
|
|
2067
|
+
+ "url": url,
|
|
2068
|
+
+ "downloaded": 0,
|
|
2069
|
+
+ "total": 0,
|
|
2070
|
+
+ "percentage": 0.0,
|
|
2071
|
+
+ "bytesPerSec": 0.0,
|
|
2072
|
+
+ "etaMs": NSNull()
|
|
2073
|
+
+ ]
|
|
2074
|
+
+ task.resume()
|
|
2075
|
+
}
|
|
2076
|
+
-
|
|
2077
|
+
+
|
|
2078
|
+
func getDownloadProgress(url: String, completion: @escaping (LlamaResult<[String: Any]>) -> Void) {
|
|
2079
|
+
- // For now, return a placeholder progress
|
|
2080
|
+
- // In a real implementation, this would track download progress
|
|
2081
|
+
- let progress: [String: Any] = [
|
|
2082
|
+
+ let progress = downloadProgressByUrl[url] ?? [
|
|
2083
|
+
"url": url,
|
|
2084
|
+
"downloaded": 0,
|
|
2085
|
+
"total": 0,
|
|
2086
|
+
@@ -852,34 +1007,150 @@ struct MinjaCaps {
|
|
2087
|
+
]
|
|
2088
|
+
completion(.success(progress))
|
|
2089
|
+
}
|
|
2090
|
+
-
|
|
2091
|
+
+
|
|
2092
|
+
func cancelDownload(url: String, completion: @escaping (LlamaResult<Bool>) -> Void) {
|
|
2093
|
+
- // For now, return success
|
|
2094
|
+
- // In a real implementation, this would cancel the ongoing download
|
|
2095
|
+
+ if let task = downloadTasksByUrl[url] {
|
|
2096
|
+
+ task.cancel()
|
|
2097
|
+
+ downloadTasksByUrl.removeValue(forKey: url)
|
|
2098
|
+
+ downloadContextsByTaskId.removeValue(forKey: task.taskIdentifier)
|
|
2099
|
+
+ }
|
|
2100
|
+
+ downloadProgressByUrl[url] = [
|
|
2101
|
+
+ "url": url,
|
|
2102
|
+
+ "downloaded": downloadProgressByUrl[url]?["downloaded"] ?? 0,
|
|
2103
|
+
+ "total": downloadProgressByUrl[url]?["total"] ?? 0,
|
|
2104
|
+
+ "percentage": downloadProgressByUrl[url]?["percentage"] ?? 0.0,
|
|
2105
|
+
+ "bytesPerSec": 0.0,
|
|
2106
|
+
+ "etaMs": NSNull(),
|
|
2107
|
+
+ "cancelled": true
|
|
2108
|
+
+ ]
|
|
2109
|
+
completion(.success(true))
|
|
2110
|
+
}
|
|
2111
|
+
-
|
|
2112
|
+
+
|
|
2113
|
+
+ public func urlSession(
|
|
2114
|
+
+ _ session: URLSession,
|
|
2115
|
+
+ downloadTask: URLSessionDownloadTask,
|
|
2116
|
+
+ didWriteData bytesWritten: Int64,
|
|
2117
|
+
+ totalBytesWritten: Int64,
|
|
2118
|
+
+ totalBytesExpectedToWrite: Int64
|
|
2119
|
+
+ ) {
|
|
2120
|
+
+ guard var context = downloadContextsByTaskId[downloadTask.taskIdentifier] else {
|
|
2121
|
+
+ return
|
|
2122
|
+
+ }
|
|
2123
|
+
+ let now = Date()
|
|
2124
|
+
+ let elapsed = max(0.001, now.timeIntervalSince(context.lastUpdatedAt))
|
|
2125
|
+
+ let delta = max(0, totalBytesWritten - context.lastBytes)
|
|
2126
|
+
+ let bytesPerSec = Double(delta) / elapsed
|
|
2127
|
+
+ context.lastBytes = totalBytesWritten
|
|
2128
|
+
+ context.lastUpdatedAt = now
|
|
2129
|
+
+ downloadContextsByTaskId[downloadTask.taskIdentifier] = context
|
|
2130
|
+
+ let total = totalBytesExpectedToWrite > 0 ? totalBytesExpectedToWrite : downloadTask.countOfBytesExpectedToReceive
|
|
2131
|
+
+ let etaMs: Any = total > totalBytesWritten && bytesPerSec > 0
|
|
2132
|
+
+ ? ((Double(total - totalBytesWritten) / bytesPerSec) * 1000.0)
|
|
2133
|
+
+ : NSNull()
|
|
2134
|
+
+ downloadProgressByUrl[context.url] = [
|
|
2135
|
+
+ "url": context.url,
|
|
2136
|
+
+ "downloaded": totalBytesWritten,
|
|
2137
|
+
+ "total": max(0, total),
|
|
2138
|
+
+ "percentage": total > 0 ? Double(totalBytesWritten) / Double(total) * 100.0 : 0.0,
|
|
2139
|
+
+ "bytesPerSec": bytesPerSec,
|
|
2140
|
+
+ "etaMs": etaMs
|
|
2141
|
+
+ ]
|
|
2142
|
+
+ }
|
|
2143
|
+
+
|
|
2144
|
+
+ public func urlSession(
|
|
2145
|
+
+ _ session: URLSession,
|
|
2146
|
+
+ downloadTask: URLSessionDownloadTask,
|
|
2147
|
+
+ didFinishDownloadingTo location: URL
|
|
2148
|
+
+ ) {
|
|
2149
|
+
+ guard let context = downloadContextsByTaskId[downloadTask.taskIdentifier] else {
|
|
2150
|
+
+ return
|
|
2151
|
+
+ }
|
|
2152
|
+
+ do {
|
|
2153
|
+
+ let fileManager = FileManager.default
|
|
2154
|
+
+ let dir = context.localURL.deletingLastPathComponent()
|
|
2155
|
+
+ try fileManager.createDirectory(at: dir, withIntermediateDirectories: true)
|
|
2156
|
+
+ if fileManager.fileExists(atPath: context.localURL.path) {
|
|
2157
|
+
+ try fileManager.removeItem(at: context.localURL)
|
|
2158
|
+
+ }
|
|
2159
|
+
+ try fileManager.moveItem(at: location, to: context.localURL)
|
|
2160
|
+
+ let total = (try? fileManager.attributesOfItem(atPath: context.localURL.path)[.size] as? NSNumber)?.int64Value ?? downloadTask.countOfBytesReceived
|
|
2161
|
+
+ downloadProgressByUrl[context.url] = [
|
|
2162
|
+
+ "url": context.url,
|
|
2163
|
+
+ "downloaded": total,
|
|
2164
|
+
+ "total": total,
|
|
2165
|
+
+ "percentage": 100.0,
|
|
2166
|
+
+ "bytesPerSec": 0.0,
|
|
2167
|
+
+ "etaMs": 0
|
|
2168
|
+
+ ]
|
|
2169
|
+
+ downloadTasksByUrl.removeValue(forKey: context.url)
|
|
2170
|
+
+ downloadContextsByTaskId.removeValue(forKey: downloadTask.taskIdentifier)
|
|
2171
|
+
+ DispatchQueue.main.async {
|
|
2172
|
+
+ context.completion(.success(context.localURL.path))
|
|
2173
|
+
+ }
|
|
2174
|
+
+ } catch {
|
|
2175
|
+
+ downloadProgressByUrl[context.url] = [
|
|
2176
|
+
+ "url": context.url,
|
|
2177
|
+
+ "downloaded": downloadTask.countOfBytesReceived,
|
|
2178
|
+
+ "total": max(0, downloadTask.countOfBytesExpectedToReceive),
|
|
2179
|
+
+ "percentage": 0.0,
|
|
2180
|
+
+ "bytesPerSec": 0.0,
|
|
2181
|
+
+ "etaMs": NSNull(),
|
|
2182
|
+
+ "error": error.localizedDescription
|
|
2183
|
+
+ ]
|
|
2184
|
+
+ downloadTasksByUrl.removeValue(forKey: context.url)
|
|
2185
|
+
+ downloadContextsByTaskId.removeValue(forKey: downloadTask.taskIdentifier)
|
|
2186
|
+
+ DispatchQueue.main.async {
|
|
2187
|
+
+ context.completion(.failure(.operationFailed("Download failed: \(error.localizedDescription)")))
|
|
2188
|
+
+ }
|
|
2189
|
+
+ }
|
|
2190
|
+
+ }
|
|
2191
|
+
+
|
|
2192
|
+
+ public func urlSession(
|
|
2193
|
+
+ _ session: URLSession,
|
|
2194
|
+
+ task: URLSessionTask,
|
|
2195
|
+
+ didCompleteWithError error: Error?
|
|
2196
|
+
+ ) {
|
|
2197
|
+
+ guard let error,
|
|
2198
|
+
+ let context = downloadContextsByTaskId[task.taskIdentifier] else {
|
|
2199
|
+
+ return
|
|
2200
|
+
+ }
|
|
2201
|
+
+ downloadProgressByUrl[context.url] = [
|
|
2202
|
+
+ "url": context.url,
|
|
2203
|
+
+ "downloaded": task.countOfBytesReceived,
|
|
2204
|
+
+ "total": max(0, task.countOfBytesExpectedToReceive),
|
|
2205
|
+
+ "percentage": 0.0,
|
|
2206
|
+
+ "bytesPerSec": 0.0,
|
|
2207
|
+
+ "etaMs": NSNull(),
|
|
2208
|
+
+ "error": error.localizedDescription
|
|
2209
|
+
+ ]
|
|
2210
|
+
+ downloadTasksByUrl.removeValue(forKey: context.url)
|
|
2211
|
+
+ downloadContextsByTaskId.removeValue(forKey: task.taskIdentifier)
|
|
2212
|
+
+ DispatchQueue.main.async {
|
|
2213
|
+
+ context.completion(.failure(.operationFailed("Download failed: \(error.localizedDescription)")))
|
|
2214
|
+
+ }
|
|
2215
|
+
+ }
|
|
2216
|
+
+
|
|
2217
|
+
func getAvailableModels(completion: @escaping (LlamaResult<[[String: Any]]>) -> Void) {
|
|
2218
|
+
let fileManager = FileManager.default
|
|
2219
|
+
var models: [[String: Any]] = []
|
|
2220
|
+
-
|
|
2221
|
+
+
|
|
2222
|
+
// Search common model directories
|
|
2223
|
+
let searchPaths = [
|
|
2224
|
+
fileManager.urls(for: .documentDirectory, in: .userDomainMask).first,
|
|
2225
|
+
fileManager.urls(for: .downloadsDirectory, in: .userDomainMask).first
|
|
2226
|
+
].compactMap { $0 }
|
|
2227
|
+
-
|
|
2228
|
+
+
|
|
2229
|
+
for searchPath in searchPaths {
|
|
2230
|
+
do {
|
|
2231
|
+
let files = try fileManager.contentsOfDirectory(at: searchPath, includingPropertiesForKeys: [.fileSizeKey, .contentModificationDateKey])
|
|
2232
|
+
-
|
|
2233
|
+
+
|
|
2234
|
+
for file in files {
|
|
2235
|
+
let pathExtension = file.pathExtension.lowercased()
|
|
2236
|
+
// Check for common model file extensions
|
|
2237
|
+
if pathExtension == "gguf" || pathExtension == "ggml" || pathExtension == "bin" {
|
|
2238
|
+
let attributes = try fileManager.attributesOfItem(atPath: file.path)
|
|
2239
|
+
let fileSize = attributes[.size] as? Int64 ?? 0
|
|
2240
|
+
-
|
|
2241
|
+
+
|
|
2242
|
+
let model: [String: Any] = [
|
|
2243
|
+
"id": file.lastPathComponent,
|
|
2244
|
+
"name": file.lastPathComponent,
|
|
2245
|
+
@@ -896,12 +1167,12 @@ struct MinjaCaps {
|
|
2246
|
+
continue
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
-
|
|
2250
|
+
+
|
|
2251
|
+
completion(.success(models))
|
|
2252
|
+
}
|
|
2253
|
+
-
|
|
2254
|
+
+
|
|
2255
|
+
// MARK: - Grammar utilities
|
|
2256
|
+
-
|
|
2257
|
+
+
|
|
2258
|
+
func convertJsonSchemaToGrammar(schema: String, completion: @escaping (LlamaResult<String>) -> Void) {
|
|
2259
|
+
// For now, return the schema as-is
|
|
2260
|
+
// In a real implementation, this would convert JSON schema to GBNF grammar
|
|
2261
|
+
diff --git a/ios/Sources/LlamaCppPlugin/LlamaCppPlugin.swift b/ios/Sources/LlamaCppPlugin/LlamaCppPlugin.swift
|
|
2262
|
+
index eaaa61c..2639810 100644
|
|
2263
|
+
--- a/ios/Sources/LlamaCppPlugin/LlamaCppPlugin.swift
|
|
2264
|
+
+++ b/ios/Sources/LlamaCppPlugin/LlamaCppPlugin.swift
|
|
2265
|
+
@@ -1,5 +1,8 @@
|
|
2266
|
+
import Foundation
|
|
2267
|
+
import Capacitor
|
|
2268
|
+
+import Darwin
|
|
2269
|
+
+import Metal
|
|
2270
|
+
+import UIKit
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Please read the Capacitor iOS Plugin Development Guide
|
|
2274
|
+
@@ -17,6 +20,7 @@ public class LlamaCppPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
2275
|
+
CAPPluginMethod(name: "initContext", returnType: CAPPluginReturnPromise),
|
|
2276
|
+
CAPPluginMethod(name: "releaseContext", returnType: CAPPluginReturnPromise),
|
|
2277
|
+
CAPPluginMethod(name: "releaseAllContexts", returnType: CAPPluginReturnPromise),
|
|
2278
|
+
+ CAPPluginMethod(name: "getHardwareInfo", returnType: CAPPluginReturnPromise),
|
|
2279
|
+
|
|
2280
|
+
// Chat and completion
|
|
2281
|
+
CAPPluginMethod(name: "getFormattedChat", returnType: CAPPluginReturnPromise),
|
|
2282
|
+
@@ -78,7 +82,75 @@ public class LlamaCppPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
2283
|
+
|
|
2284
|
+
private let implementation = LlamaCpp()
|
|
2285
|
+
|
|
2286
|
+
+ private func machineIdentifier() -> String {
|
|
2287
|
+
+ var systemInfo = utsname()
|
|
2288
|
+
+ uname(&systemInfo)
|
|
2289
|
+
+ return withUnsafePointer(to: &systemInfo.machine) { ptr in
|
|
2290
|
+
+ ptr.withMemoryRebound(to: CChar.self, capacity: 1) { cString in
|
|
2291
|
+
+ String(cString: cString)
|
|
2292
|
+
+ }
|
|
2293
|
+
+ }
|
|
2294
|
+
+ }
|
|
2295
|
+
+
|
|
2296
|
+
+ private func thermalStateString(_ state: ProcessInfo.ThermalState) -> String {
|
|
2297
|
+
+ switch state {
|
|
2298
|
+
+ case .nominal:
|
|
2299
|
+
+ return "nominal"
|
|
2300
|
+
+ case .fair:
|
|
2301
|
+
+ return "fair"
|
|
2302
|
+
+ case .serious:
|
|
2303
|
+
+ return "serious"
|
|
2304
|
+
+ case .critical:
|
|
2305
|
+
+ return "critical"
|
|
2306
|
+
+ @unknown default:
|
|
2307
|
+
+ return "unknown"
|
|
2308
|
+
+ }
|
|
2309
|
+
+ }
|
|
2310
|
+
+
|
|
2311
|
+
+ private func freeStorageGb() -> Double? {
|
|
2312
|
+
+ guard let attrs = try? FileManager.default.attributesOfFileSystem(
|
|
2313
|
+
+ forPath: NSHomeDirectory()
|
|
2314
|
+
+ ) else {
|
|
2315
|
+
+ return nil
|
|
2316
|
+
+ }
|
|
2317
|
+
+ let free = attrs[.systemFreeSize] as? NSNumber
|
|
2318
|
+
+ return free.map { $0.doubleValue / 1_073_741_824.0 }
|
|
2319
|
+
+ }
|
|
2320
|
+
+
|
|
2321
|
+
// MARK: - Core initialization and management
|
|
2322
|
+
+
|
|
2323
|
+
+ @objc func getHardwareInfo(_ call: CAPPluginCall) {
|
|
2324
|
+
+ let totalRamGb = Double(ProcessInfo.processInfo.physicalMemory) / 1_073_741_824.0
|
|
2325
|
+
+ let gpuAvailable = MTLCreateSystemDefaultDevice() != nil
|
|
2326
|
+
+ var result: [String: Any] = [
|
|
2327
|
+
+ "platform": "ios",
|
|
2328
|
+
+ "deviceModel": UIDevice.current.model,
|
|
2329
|
+
+ "machineId": machineIdentifier(),
|
|
2330
|
+
+ "osVersion": UIDevice.current.systemVersion,
|
|
2331
|
+
+ "totalRamGb": totalRamGb,
|
|
2332
|
+
+ "availableRamGb": NSNull(),
|
|
2333
|
+
+ "cpuCores": ProcessInfo.processInfo.processorCount,
|
|
2334
|
+
+ "gpu": [
|
|
2335
|
+
+ "backend": "metal",
|
|
2336
|
+
+ "available": gpuAvailable
|
|
2337
|
+
+ ],
|
|
2338
|
+
+ "gpuSupported": gpuAvailable,
|
|
2339
|
+
+ "lowPowerMode": ProcessInfo.processInfo.isLowPowerModeEnabled,
|
|
2340
|
+
+ "thermalState": thermalStateString(ProcessInfo.processInfo.thermalState),
|
|
2341
|
+
+ "dflashSupported": false,
|
|
2342
|
+
+ "dflashReason": "DFlash requires the buun-llama-cpp fork and is not exported by this mobile framework yet.",
|
|
2343
|
+
+ "source": "native"
|
|
2344
|
+
+ ]
|
|
2345
|
+
+ if let freeStorage = freeStorageGb() {
|
|
2346
|
+
+ result["freeStorageGb"] = freeStorage
|
|
2347
|
+
+ }
|
|
2348
|
+
+ #if targetEnvironment(simulator)
|
|
2349
|
+
+ result["isSimulator"] = true
|
|
2350
|
+
+ #else
|
|
2351
|
+
+ result["isSimulator"] = false
|
|
2352
|
+
+ #endif
|
|
2353
|
+
+ call.resolve(result)
|
|
2354
|
+
+ }
|
|
2355
|
+
|
|
2356
|
+
@objc func toggleNativeLog(_ call: CAPPluginCall) {
|
|
2357
|
+
let enabled = call.getBool("enabled") ?? false
|
|
2358
|
+
diff --git a/package.json b/package.json
|
|
2359
|
+
index 37d536f..2abe69a 100644
|
|
2360
|
+
--- a/package.json
|
|
2361
|
+
+++ b/package.json
|
|
2362
|
+
@@ -18,6 +18,7 @@
|
|
2363
|
+
"ios/CMakeLists-x86_64.txt",
|
|
2364
|
+
"ios/Sources",
|
|
2365
|
+
"ios/Frameworks",
|
|
2366
|
+
+ "ios/Frameworks-xcframework",
|
|
2367
|
+
"Package.swift",
|
|
2368
|
+
"LlamaCpp.podspec",
|
|
2369
|
+
"LlamaCppCapacitor.podspec",
|
|
2370
|
+
diff --git a/types/llama-cpp-capacitor.d.ts b/types/llama-cpp-capacitor.d.ts
|
|
2371
|
+
index 61e2672..cb687cb 100644
|
|
2372
|
+
--- a/types/llama-cpp-capacitor.d.ts
|
|
2373
|
+
+++ b/types/llama-cpp-capacitor.d.ts
|
|
2374
|
+
@@ -29,6 +29,13 @@ declare module 'llama-cpp-capacitor' {
|
|
2375
|
+
n_cpu_moe?: number;
|
|
2376
|
+
embedding?: boolean;
|
|
2377
|
+
embd_normalize?: number;
|
|
2378
|
+
+ draft_model?: string;
|
|
2379
|
+
+ n_ctx_draft?: number;
|
|
2380
|
+
+ draft_min?: number;
|
|
2381
|
+
+ draft_max?: number;
|
|
2382
|
+
+ speculative_samples?: number;
|
|
2383
|
+
+ mobile_speculative?: boolean;
|
|
2384
|
+
+ reasoning?: boolean;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
export interface NativeCompletionParams {
|