@legendapp/spark 0.0.1-next.10
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/LICENSE +21 -0
- package/README.md +27 -0
- package/ai-codex.ts +1 -0
- package/ai.ts +1 -0
- package/app-documents.ts +1 -0
- package/app.ts +1 -0
- package/audio.ts +1 -0
- package/auth-session.ts +1 -0
- package/bin/spark.cjs +5 -0
- package/camera.ts +13 -0
- package/clipboard.ts +1 -0
- package/config-plugin.cjs +1 -0
- package/config-plugin.d.cts +2 -0
- package/config.cjs +1 -0
- package/config.d.cts +1 -0
- package/context-menu.ts +1 -0
- package/contracts.ts +2 -0
- package/customize.ts +2 -0
- package/diagnostics.ts +1 -0
- package/dialogs.ts +2 -0
- package/drag-drop.ts +1 -0
- package/expo-config.cjs +1 -0
- package/expo-config.d.cts +1 -0
- package/files.ts +1 -0
- package/global-shortcuts.ts +1 -0
- package/html.ts +1 -0
- package/init-template.cjs +2 -0
- package/links.ts +1 -0
- package/markdown.ts +1 -0
- package/menus.ts +1 -0
- package/metro-gate.cjs +1 -0
- package/metro.cjs +4 -0
- package/metro.d.cts +12 -0
- package/native.cjs +3 -0
- package/native.d.cts +6 -0
- package/notifications.ts +1 -0
- package/package.json +248 -0
- package/patches/camera/react-native-nitro-image.patch +320 -0
- package/patches/camera/react-native-nitro-modules.patch +50 -0
- package/patches/camera/react-native-vision-camera.patch +2662 -0
- package/patches/camera/upstream.json +22 -0
- package/patches/dependencies.json +14 -0
- package/patches/react-native-enriched-html@1.1.1.patch +854 -0
- package/patches/react-native-enriched-markdown@1.1.1.patch +7751 -0
- package/postinstall.cjs +1 -0
- package/processes.ts +1 -0
- package/runtime-entry.cjs +1 -0
- package/schema.json +636 -0
- package/secure-storage.ts +1 -0
- package/settings-observable.ts +1 -0
- package/settings-window.ts +1 -0
- package/settings.ts +1 -0
- package/shortcuts-commands.ts +1 -0
- package/shortcuts-keyboard.ts +3 -0
- package/shortcuts.ts +1 -0
- package/skills/spark/SKILL.md +56 -0
- package/skills/spark/UPGRADING.md +322 -0
- package/sqlite.ts +1 -0
- package/system.ts +1 -0
- package/tray.ts +1 -0
- package/ui-classnames.ts +1 -0
- package/ui-glass.ts +1 -0
- package/ui-search.ts +1 -0
- package/ui-sidebar.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-swipe.ts +1 -0
- package/ui-symbol.ts +1 -0
- package/ui-uniwind.ts +1 -0
- package/ui.ts +1 -0
- package/updates.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +19 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/availability.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/index.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.cjs +11 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocation-command.d.cts +2 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/invocations.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/output.ts +62 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/run.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-ai/src/types.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-audio/RNSparkAudio.podspec +18 -0
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.h +5 -0
- package/vendor/node_modules/@legendapp/spark-audio/macos/RNSparkAudio.mm +256 -0
- package/vendor/node_modules/@legendapp/spark-audio/package.json +52 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/NativeSparkAudio.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/desktop.ts +43 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/events.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/hooks.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.android.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.ios.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.web.ts +101 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/index.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session-unavailable.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.ts +58 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/media-session.web.ts +43 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/media-types.ts +59 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/mobile.ts +46 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/player.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/status-listeners.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-audio/src/types.ts +26 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.def +3 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.h +193 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/SparkAudio.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-audio/windows/SparkAudio.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +42 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/core.ts +86 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.android.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ios.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.ts +38 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/index.web.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/mobile.ts +108 -0
- package/vendor/node_modules/@legendapp/spark-auth-session/src/types.ts +49 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +207 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build-mode.js +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +379 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +61 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +113 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +160 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/credentials.js +130 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-ai.cjs +108 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-artifacts.js +315 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-cli.cjs +75 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-github.cjs +133 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-policy.cjs +102 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-provider.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/customize-worker.cjs +273 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +157 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +415 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +128 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +100 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +43 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/executable.js +19 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-extension.cjs +51 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +69 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-preload.cjs +19 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-metro.cjs +41 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-native.cjs +14 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/expo-node.js +21 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/go-profile.js +20 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/helpers.js +79 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +280 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +26 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/js-runtime.cjs +96 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/json.js +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/local.js +124 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/macos-release.js +11 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro-gate.cjs +33 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +84 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.js +25 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +152 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +184 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.d.cts +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-metadata.js +26 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +88 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-preparation.js +88 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/notary-profiles.js +75 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/npm-bin/npm +6 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/npm-bin/npm.cmd +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/pack-archive.js +23 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager-config.js +43 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package-manager.js +58 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/package.js +201 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/platform.js +48 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/process.js +64 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +419 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-driver.js +35 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.js +123 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +42 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runner-install.js +254 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.ps1 +87 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-bootstrap.sh +107 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-downloads.tsv +13 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-entry.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-install.js +71 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/sdk-transfer.js +113 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/session-status.js +26 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/signing.js +176 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/universal.cjs +29 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +157 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +102 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows-associations.js +45 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows-associations.ps1 +57 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows-geometry.js +33 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows-metro.js +112 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +137 -0
- package/vendor/node_modules/@legendapp/spark-cli/package.json +25 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/App.tsx +23 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/app.json +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/assets/icon.png +0 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/desktop.config.json +21 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/gitignore +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/index.ts +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/metro.config.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +102 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/tsconfig.json +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/App.tsx +34 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.macos.tsx +13 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/Git.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/diff-lite/compare.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/App.tsx +34 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.macos.tsx +59 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.tsx +13 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.web.tsx +14 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/Integration.windows.tsx +59 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/document.ts +58 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.desktop.ts +27 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.macos.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.ts +31 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.web.ts +21 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/io.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/sessions.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/document-editor/useDocument.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.desktop.tsx +25 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.macos.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.tsx +14 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.web.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/Lifecycle.windows.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.desktop.tsx +23 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.macos.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.tsx +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/OpenFiles.windows.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/document.ts +58 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.desktop.ts +27 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.macos.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.ts +31 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.web.ts +21 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/io.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/lifecycle-types.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/lifetime.ts +23 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/records.ts +51 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/storage.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/example-shared/useModel.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.desktop.tsx +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.macos.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/Activation.windows.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/App.tsx +38 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.desktop.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.macos.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.ts +18 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.web.ts +37 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/assets.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/model.ts +91 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/music-lite/store.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.desktop.tsx +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.macos.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Activation.windows.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/App.tsx +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.desktop.ts +47 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.macos.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Desktop.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/Theme.tsx +17 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/model.ts +61 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/search.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/session.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/store.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/notes-lite/window-session.ts +63 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/App.tsx +57 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/app.json +19 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/assets/icon.png +0 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/desktop.config.json +64 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/gitignore +11 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/global.css +31 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/metro.config.js +7 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +116 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/react-native.config.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/tsconfig.json +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/uniwind-types.d.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/.claude/skills/spark/SKILL.md +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/AGENTS.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/App.tsx +16 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/CLAUDE.md +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/README.md +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/app.json +15 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/assets/icon.png +0 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/desktop.config.json +10 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/gitignore +9 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/index.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/metro.config.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +103 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/react-native.config.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/tsconfig.json +10 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/RNDesktopClipboard.podspec +16 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.h +4 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +81 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +52 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/NativeDesktopClipboard.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +63 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/expo.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/formats.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/index.android.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/index.ios.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/index.web.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/index.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/options.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/src/types.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.def +3 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.h +142 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj +145 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/SparkClipboard.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-clipboard/windows/SparkClipboard.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-codex/RNCodex.podspec +22 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.hpp +23 -0
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +1541 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitro.json +21 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/.gitattributes +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex+autolinking.rb +62 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.cpp +17 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Bridge.hpp +27 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodex-Swift-Cxx-Umbrella.hpp +38 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.mm +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/ios/RNCodexAutolinking.swift +16 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexAvailability.hpp +95 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/CodexRunResult.hpp +99 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.cpp +24 -0
- package/vendor/node_modules/@legendapp/spark-codex/nitrogen/generated/shared/c++/HybridCodexAppServerSpec.hpp +71 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +35 -0
- package/vendor/node_modules/@legendapp/spark-codex/react-native.config.js +11 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/Codex.nitro.ts +30 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/index.ts +65 -0
- package/vendor/node_modules/@legendapp/spark-codex/src/native.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-commands/package.json +21 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/bindings.ts +90 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/index.tsx +400 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/router.ts +138 -0
- package/vendor/node_modules/@legendapp/spark-commands/src/storage.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/RNContextMenu.podspec +16 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.h +9 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/macos/RNContextMenu.mm +159 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +47 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/src/NativeContextMenu.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/src/index.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.def +3 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.h +113 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/SparkContextMenu.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-context-menu/windows/SparkContextMenu.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryJSI.hpp +89 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/cpp/SparkBinaryWindows.hpp +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +60 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkBinaryJSI.h +48 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +35 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +198 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktopError.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.h +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.mm +207 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.h +26 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkLifecycle.mm +49 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkQuitCoordinator.mm +70 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +44 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +349 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +86 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/recent-documents/RNRecentDocumentController.mm +55 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +41 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/NativeDesktopApp.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +121 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/accelerator.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/index.ts +56 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +130 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/native-buffer.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/path.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize-hooks.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/customize.ts +117 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/events.ts +75 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/index.windows.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/open-requests.ts +43 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/restoration.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/transport.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +50 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +107 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +42 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +177 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +113 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/customize-provider.cjs +16 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/customize.cjs +16 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/entitlements.cjs +23 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.cjs +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/expo.d.cts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/fabric-lifecycle.cjs +125 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/helpers.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +29 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/keyboard-events.cjs +44 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/lifecycle.cjs +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +106 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +21 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +144 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +60 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +112 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +636 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.cjs +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.d.cts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +47 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +36 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +73 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +209 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/SparkCustomize.mm +517 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +14 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/SparkComponentGeometry.h +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +849 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/launch.inc +67 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/notifications.inc +60 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/runtime.inc +63 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/runtimes.inc +162 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/RNDesktopLinks.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/common/AuthLoopback.h +119 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/macos/RNDesktopLinks.mm +80 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +53 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/NativeDesktopLinks.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/api.ts +31 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/expo.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.android.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.ios.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.web.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/src/native.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.def +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.h +128 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/SparkLinks.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/windows/SparkLinks.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/RNDesktopShortcuts.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/RNDesktopShortcuts.mm +58 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.h +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/macos/keyboard-manager/RNKeyboardManager.mm +307 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/NativeDesktopShortcuts.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/api.ts +45 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/index.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/NativeKeyboardManager.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/codes.ts +108 -0
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/src/keyboard-manager/index.ts +99 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +22 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +339 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/SparkWindowGeometry.h +63 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.h +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/LegendWindowRegistry.mm +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.h +12 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +3189 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManagerStartup.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/SidebarStartupFallbacks.mm +14 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +48 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/NativeDesktopWindowManager.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +192 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/diagnostics.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/index.windows.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos.ts +51 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/transport.ts +41 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +140 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +162 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/window-manager/NativeWindowManager.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/WindowProvider.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +78 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/index.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/types.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +18 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-documents/package.json +22 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/controller.ts +97 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/documentTransition.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/hooks.ts +139 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/index.tsx +50 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/reload.ts +39 -0
- package/vendor/node_modules/@legendapp/spark-documents/src/requests.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/RNDesktopDrag.podspec +20 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.h +4 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +94 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +45 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +83 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +60 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.cpp +21 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.def +3 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +215 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/RNFileDialog.podspec +18 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.h +9 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +261 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +50 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/NativeFileDialog.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +36 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +74 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +42 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.def +3 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.h +112 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/SparkFileDialog.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/windows/SparkFileDialog.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-file-system/RNDesktopFileSystem.podspec +18 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.h +4 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +222 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.h +25 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/SparkFileMutations.mm +216 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.h +9 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScanner.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.h +47 -0
- package/vendor/node_modules/@legendapp/spark-file-system/macos/file-scanner/RNFileScannerCore.mm +306 -0
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +49 -0
- package/vendor/node_modules/@legendapp/spark-file-system/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/NativeDesktopFileSystem.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/NativeFileScanner.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/file-scanner/index.ts +93 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/handles.ts +79 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/index.ts +150 -0
- package/vendor/node_modules/@legendapp/spark-file-system/src/path.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.def +3 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.h +371 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj +146 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/SparkFileSystem.vcxproj.filters +45 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/Trash.h +52 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-file-system/windows/SparkFileSystem.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/RNDesktopGlobalShortcuts.podspec +18 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.h +3 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/macos/RNDesktopGlobalShortcuts.mm +68 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +47 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/NativeDesktopGlobalShortcuts.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/src/index.ts +45 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.def +3 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.h +81 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/SparkGlobalShortcuts.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/windows/SparkGlobalShortcuts.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-html/package.json +24 -0
- package/vendor/node_modules/@legendapp/spark-html/src/Html.tsx +22 -0
- package/vendor/node_modules/@legendapp/spark-html/src/HtmlInput.tsx +102 -0
- package/vendor/node_modules/@legendapp/spark-html/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-html/src/types.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +24 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +25 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/MarkdownInput.tsx +111 -0
- package/vendor/node_modules/@legendapp/spark-markdown/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/RNDesktopMessageDialog.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.h +3 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +137 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/NativeDesktopMessageDialog.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +146 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.def +3 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.h +145 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/SparkMessageDialog.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-message-dialog/windows/SparkMessageDialog.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/RNNativeMenu.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.h +10 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +272 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/NativeMenu.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +128 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +103 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/index.windows.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/src/windows-menus.ts +49 -0
- package/vendor/node_modules/@legendapp/spark-notifications/RNDesktopNotifications.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.h +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/macos/RNDesktopNotifications.mm +156 -0
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-notifications/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-notifications/src/NativeDesktopNotifications.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/src/index.ts +141 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.def +3 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.h +175 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/SparkNotifications.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-notifications/windows/SparkNotifications.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-processes/RNDesktopProcesses.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.h +3 -0
- package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.mm +226 -0
- package/vendor/node_modules/@legendapp/spark-processes/package.json +47 -0
- package/vendor/node_modules/@legendapp/spark-processes/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-processes/src/NativeDesktopProcesses.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-processes/src/index.ts +135 -0
- package/vendor/node_modules/@legendapp/spark-processes/src/types.ts +34 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.def +3 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.h +220 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj +145 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/SparkProcesses.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-processes/windows/SparkProcesses.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +18 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/components.tsx +52 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/index.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/types.ts +24 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.macos.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputShortcuts.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/useInputValue.ts +14 -0
- package/vendor/node_modules/@legendapp/spark-rich-text/src/value.ts +16 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/RNDesktopSecureStorage.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.h +4 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/macos/RNDesktopSecureStorage.mm +62 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +52 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/NativeDesktopSecureStorage.ts +6 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/desktop.ts +26 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/expo.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.android.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.ios.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.web.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.windows.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/options.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/src/unavailable.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.def +3 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.h +48 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/SparkSecureStorage.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-secure-storage/windows/SparkSecureStorage.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-settings/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/fileStorage.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/filename.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/filename.windows.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/index.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/storage/index.ts +142 -0
- package/vendor/node_modules/@legendapp/spark-settings/src/store.ts +79 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +439 -0
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/options.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +16 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/src/database.ts +182 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/src/index.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-sqlite/src/types.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-system/RNDesktopSystem.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.h +3 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +143 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.h +9 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.h +24 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.mm +101 -0
- package/vendor/node_modules/@legendapp/spark-system/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-system/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-system/src/NativeDesktopSystem.ts +3 -0
- package/vendor/node_modules/@legendapp/spark-system/src/index.ts +158 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.def +3 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.h +158 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/SparkSystem.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-system/windows/SparkSystem.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-tray/RNDesktopTray.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.h +4 -0
- package/vendor/node_modules/@legendapp/spark-tray/macos/RNDesktopTray.mm +75 -0
- package/vendor/node_modules/@legendapp/spark-tray/package.json +46 -0
- package/vendor/node_modules/@legendapp/spark-tray/react-native.config.js +6 -0
- package/vendor/node_modules/@legendapp/spark-tray/src/NativeDesktopTray.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +103 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.cpp +20 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.def +3 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.h +163 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.vcxproj +143 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/SparkTray.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-tray/windows/SparkTray.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-ui/RNSparkUI.podspec +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +54 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkLayoutDirection.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +58 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +1554 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +76 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +198 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +184 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +159 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.h +18 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +708 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.h +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +446 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.h +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +188 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +74 -0
- package/vendor/node_modules/@legendapp/spark-ui/react-native.config.js +5 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkSelectNativeComponent.ts +12 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +42 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +94 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/classnames/index.ts +8 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +42 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +56 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/glass-effect-view/index.tsx +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +39 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +59 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +54 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/index.windows.tsx +1 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSelectNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/select.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/SFSymbolNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sf-symbol/index.tsx +27 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +25 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +115 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/specialized.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/SwipeActionsNativeComponent.ts +11 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/swipe-actions/index.tsx +41 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/TextInputSearchNativeComponent.ts +33 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/text-input-search/index.tsx +34 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -0
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +10 -0
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +19 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/ExperimentalFeatures.props +33 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/LICENSE +25 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.cpp +21 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.h +24 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/ReactPackageProvider.idl +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkAppearance.h +61 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.cpp +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.def +3 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +186 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.rc +0 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.vcxproj +144 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.vcxproj.filters +44 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/pch.cpp +1 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/pch.h +30 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/resource.h +5 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/targetver.h +8 -0
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI.sln +43 -0
- package/vendor/node_modules/@legendapp/spark-updates/RNDesktopUpdates.podspec +18 -0
- package/vendor/node_modules/@legendapp/spark-updates/Sparkle.podspec.json +39 -0
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.h +4 -0
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +97 -0
- package/vendor/node_modules/@legendapp/spark-updates/macos/SparkUpdateState.h +39 -0
- package/vendor/node_modules/@legendapp/spark-updates/package.json +44 -0
- package/vendor/node_modules/@legendapp/spark-updates/src/NativeDesktopUpdates.ts +5 -0
- package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +115 -0
- package/vendor/node_modules/@legendapp/spark-webview/package.json +15 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/WebView.tsx +11 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/adapter.ts +55 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/index.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/types.ts +32 -0
- package/vendor/node_modules/@legendapp/spark-webview/src/view-props.ts +28 -0
- package/vendor/node_modules/@legendapp/spark-window-options/index.cjs +62 -0
- package/vendor/node_modules/@legendapp/spark-window-options/index.d.ts +25 -0
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +12 -0
- package/webview.ts +1 -0
- package/windows-macos.ts +1 -0
- package/windows.ts +1 -0
|
@@ -0,0 +1,1541 @@
|
|
|
1
|
+
#if !defined(SPARK_CODEX_TESTING)
|
|
2
|
+
#include "HybridCodexAppServer.hpp"
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
#import <Foundation/Foundation.h>
|
|
6
|
+
|
|
7
|
+
#include <algorithm>
|
|
8
|
+
#include <cerrno>
|
|
9
|
+
#include <chrono>
|
|
10
|
+
#include <cmath>
|
|
11
|
+
#include <cctype>
|
|
12
|
+
#include <condition_variable>
|
|
13
|
+
#include <csignal>
|
|
14
|
+
#include <cstdint>
|
|
15
|
+
#include <cstdlib>
|
|
16
|
+
#include <cstring>
|
|
17
|
+
#include <deque>
|
|
18
|
+
#include <fcntl.h>
|
|
19
|
+
#include <map>
|
|
20
|
+
#include <mutex>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <poll.h>
|
|
23
|
+
#include <set>
|
|
24
|
+
#include <spawn.h>
|
|
25
|
+
#include <stdexcept>
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <sys/types.h>
|
|
28
|
+
#include <sys/wait.h>
|
|
29
|
+
#include <thread>
|
|
30
|
+
#include <unistd.h>
|
|
31
|
+
#include <vector>
|
|
32
|
+
|
|
33
|
+
extern char** environ;
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::legendapps::codex {
|
|
36
|
+
|
|
37
|
+
#if defined(SPARK_CODEX_TESTING)
|
|
38
|
+
struct CodexAvailability {
|
|
39
|
+
bool available; std::string codexPath; std::string message; std::string userAgent;
|
|
40
|
+
CodexAvailability(bool available, std::string codexPath, std::string message, std::string userAgent)
|
|
41
|
+
: available(available), codexPath(std::move(codexPath)), message(std::move(message)), userAgent(std::move(userAgent)) {}
|
|
42
|
+
};
|
|
43
|
+
struct CodexRunResult {
|
|
44
|
+
std::string model; std::string output; std::string threadId; std::string turnId; std::string userAgent;
|
|
45
|
+
CodexRunResult(std::string model, std::string output, std::string threadId, std::string turnId, std::string userAgent)
|
|
46
|
+
: model(std::move(model)), output(std::move(output)), threadId(std::move(threadId)), turnId(std::move(turnId)), userAgent(std::move(userAgent)) {}
|
|
47
|
+
};
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
namespace {
|
|
51
|
+
|
|
52
|
+
constexpr size_t kMaximumMessageBytes = 16 * 1024 * 1024;
|
|
53
|
+
constexpr size_t kMaximumStderrBytes = 16 * 1024;
|
|
54
|
+
constexpr double kInitializeTimeoutMs = 15'000;
|
|
55
|
+
constexpr double kMaximumRunTimeoutMs = 86'400'000;
|
|
56
|
+
constexpr size_t kMaximumPreAckBytes = kMaximumMessageBytes;
|
|
57
|
+
|
|
58
|
+
using Clock = std::chrono::steady_clock;
|
|
59
|
+
|
|
60
|
+
std::string toString(NSString* value) {
|
|
61
|
+
if (value == nil) {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
const char* utf8 = value.UTF8String;
|
|
65
|
+
return utf8 == nullptr ? std::string() : std::string(utf8);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
NSString* toNSString(const std::string& value) {
|
|
69
|
+
return [[NSString alloc] initWithBytes:value.data()
|
|
70
|
+
length:value.size()
|
|
71
|
+
encoding:NSUTF8StringEncoding] ?: @"";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
NSDictionary* parseJsonObject(const std::string& json, const std::string& context) {
|
|
75
|
+
NSData* data = [NSData dataWithBytes:json.data() length:json.size()];
|
|
76
|
+
NSError* error = nil;
|
|
77
|
+
id value = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
|
78
|
+
if (![value isKindOfClass:[NSDictionary class]]) {
|
|
79
|
+
std::string detail = error == nil ? "expected a JSON object" : toString(error.localizedDescription);
|
|
80
|
+
throw std::runtime_error(context + ": " + detail);
|
|
81
|
+
}
|
|
82
|
+
return (NSDictionary*)value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
std::string serializeJson(NSDictionary* value) {
|
|
86
|
+
NSError* error = nil;
|
|
87
|
+
NSData* data = [NSJSONSerialization dataWithJSONObject:value options:0 error:&error];
|
|
88
|
+
if (data == nil) {
|
|
89
|
+
throw std::runtime_error("Could not encode a Codex app-server request: " + toString(error.localizedDescription));
|
|
90
|
+
}
|
|
91
|
+
return std::string(static_cast<const char*>(data.bytes), data.length);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
NSDictionary* dictionaryValue(id value) {
|
|
95
|
+
return [value isKindOfClass:[NSDictionary class]] ? (NSDictionary*)value : nil;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
NSArray* arrayValue(id value) {
|
|
99
|
+
return [value isKindOfClass:[NSArray class]] ? (NSArray*)value : nil;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
NSString* stringValue(id value) {
|
|
103
|
+
return [value isKindOfClass:[NSString class]] ? (NSString*)value : nil;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
bool boolValue(id value) {
|
|
107
|
+
return [value respondsToSelector:@selector(boolValue)] && [value boolValue];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
std::string responseError(NSDictionary* response) {
|
|
111
|
+
NSDictionary* error = dictionaryValue(response[@"error"]);
|
|
112
|
+
if (error == nil) {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
NSString* message = stringValue(error[@"message"]);
|
|
116
|
+
if (message != nil) {
|
|
117
|
+
return toString(message);
|
|
118
|
+
}
|
|
119
|
+
return toString([error description]);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
bool containsInsensitive(const std::string& value, const std::string& needle) {
|
|
123
|
+
std::string lowerValue(value);
|
|
124
|
+
std::string lowerNeedle(needle);
|
|
125
|
+
std::transform(lowerValue.begin(), lowerValue.end(), lowerValue.begin(), ::tolower);
|
|
126
|
+
std::transform(lowerNeedle.begin(), lowerNeedle.end(), lowerNeedle.begin(), ::tolower);
|
|
127
|
+
return lowerValue.find(lowerNeedle) != std::string::npos;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
std::string actionableError(const std::string& message) {
|
|
131
|
+
if (message.empty()) {
|
|
132
|
+
return "Codex failed without an error message. Run `codex login` in Terminal, then try again.";
|
|
133
|
+
}
|
|
134
|
+
if (containsInsensitive(message, "auth") || containsInsensitive(message, "login") ||
|
|
135
|
+
containsInsensitive(message, "unauthorized") || containsInsensitive(message, "401")) {
|
|
136
|
+
if (containsInsensitive(message, "codex login")) {
|
|
137
|
+
return message;
|
|
138
|
+
}
|
|
139
|
+
return message + " Run `codex login` in Terminal, then try again.";
|
|
140
|
+
}
|
|
141
|
+
if (containsInsensitive(message, "rate limit") || containsInsensitive(message, "usage limit") ||
|
|
142
|
+
containsInsensitive(message, "quota")) {
|
|
143
|
+
return message + " Wait for your Codex usage limit to reset, or select another model in Codex.";
|
|
144
|
+
}
|
|
145
|
+
if (containsInsensitive(message, "method not found") || containsInsensitive(message, "invalid params") ||
|
|
146
|
+
containsInsensitive(message, "protocol")) {
|
|
147
|
+
return message + " Update Codex to a version that supports app-server, then reopen the app.";
|
|
148
|
+
}
|
|
149
|
+
return message;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
std::string resolveCodexPath() {
|
|
153
|
+
@autoreleasepool {
|
|
154
|
+
NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
155
|
+
NSMutableArray<NSString*>* candidates = [NSMutableArray array];
|
|
156
|
+
NSString* explicitPath = NSProcessInfo.processInfo.environment[@"CODEX_PATH"];
|
|
157
|
+
if (explicitPath.length > 0) {
|
|
158
|
+
[candidates addObject:[explicitPath stringByExpandingTildeInPath]];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
NSString* path = NSProcessInfo.processInfo.environment[@"PATH"];
|
|
162
|
+
for (NSString* directory in [path componentsSeparatedByString:@":"]) {
|
|
163
|
+
if (directory.length > 0) {
|
|
164
|
+
[candidates addObject:[directory stringByAppendingPathComponent:@"codex"]];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
NSString* home = NSHomeDirectory();
|
|
169
|
+
[candidates addObjectsFromArray:@[
|
|
170
|
+
[home stringByAppendingPathComponent:@".local/bin/codex"],
|
|
171
|
+
[home stringByAppendingPathComponent:@".bun/bin/codex"],
|
|
172
|
+
[home stringByAppendingPathComponent:@"bin/codex"],
|
|
173
|
+
@"/opt/homebrew/bin/codex",
|
|
174
|
+
@"/usr/local/bin/codex",
|
|
175
|
+
@"/usr/bin/codex",
|
|
176
|
+
]];
|
|
177
|
+
|
|
178
|
+
NSMutableSet<NSString*>* visited = [NSMutableSet set];
|
|
179
|
+
for (NSString* candidate in candidates) {
|
|
180
|
+
NSString* standardized = candidate.stringByStandardizingPath;
|
|
181
|
+
if ([visited containsObject:standardized]) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
[visited addObject:standardized];
|
|
185
|
+
BOOL isDirectory = NO;
|
|
186
|
+
if ([fileManager fileExistsAtPath:standardized isDirectory:&isDirectory] && !isDirectory &&
|
|
187
|
+
[fileManager isExecutableFileAtPath:standardized]) {
|
|
188
|
+
return toString(standardized);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
NSString* defaultWorkingDirectory();
|
|
196
|
+
|
|
197
|
+
NSString* isolatedCodexHome() {
|
|
198
|
+
NSString* bundleIdentifier = NSBundle.mainBundle.bundleIdentifier ?: @"legend-apps";
|
|
199
|
+
NSString* path = [defaultWorkingDirectory()
|
|
200
|
+
stringByAppendingPathComponent:[@"codex-home-" stringByAppendingString:bundleIdentifier]];
|
|
201
|
+
NSFileManager* fileManager = NSFileManager.defaultManager;
|
|
202
|
+
[fileManager createDirectoryAtPath:path
|
|
203
|
+
withIntermediateDirectories:YES
|
|
204
|
+
attributes:nil
|
|
205
|
+
error:nil];
|
|
206
|
+
[fileManager setAttributes:@{NSFilePosixPermissions: @(0700)} ofItemAtPath:path error:nil];
|
|
207
|
+
|
|
208
|
+
NSString* sourceCodexHome = NSProcessInfo.processInfo.environment[@"CODEX_HOME"];
|
|
209
|
+
if (sourceCodexHome.length == 0) {
|
|
210
|
+
sourceCodexHome = [NSHomeDirectory() stringByAppendingPathComponent:@".codex"];
|
|
211
|
+
}
|
|
212
|
+
NSString* sourceAuthPath = [sourceCodexHome stringByAppendingPathComponent:@"auth.json"];
|
|
213
|
+
NSString* targetAuthPath = [path stringByAppendingPathComponent:@"auth.json"];
|
|
214
|
+
if ([fileManager fileExistsAtPath:sourceAuthPath] && ![fileManager fileExistsAtPath:targetAuthPath]) {
|
|
215
|
+
[fileManager createSymbolicLinkAtPath:targetAuthPath withDestinationPath:sourceAuthPath error:nil];
|
|
216
|
+
}
|
|
217
|
+
return path;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
std::vector<std::string> sanitizedEnvironmentStorage() {
|
|
221
|
+
static const std::set<std::string> excluded = {
|
|
222
|
+
"CODEX_CI",
|
|
223
|
+
"CODEX_CLI_AUTH_CREDENTIALS_STORE",
|
|
224
|
+
"CODEX_HOME",
|
|
225
|
+
"CODEX_INTERNAL_ORIGINATOR_OVERRIDE",
|
|
226
|
+
"CODEX_SESSION_ID",
|
|
227
|
+
"CODEX_SHELL",
|
|
228
|
+
"CODEX_THREAD_ID",
|
|
229
|
+
};
|
|
230
|
+
std::vector<std::string> values;
|
|
231
|
+
for (char** entry = environ; entry != nullptr && *entry != nullptr; ++entry) {
|
|
232
|
+
std::string value(*entry);
|
|
233
|
+
const size_t separator = value.find('=');
|
|
234
|
+
const std::string key = value.substr(0, separator);
|
|
235
|
+
if (!excluded.contains(key)) {
|
|
236
|
+
values.push_back(std::move(value));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
values.push_back("CODEX_CLI_AUTH_CREDENTIALS_STORE=file");
|
|
240
|
+
values.push_back("CODEX_HOME=" + toString(isolatedCodexHome()));
|
|
241
|
+
return values;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
NSMutableDictionary<NSString*, NSString*>* sanitizedEnvironmentDictionary() {
|
|
245
|
+
NSMutableDictionary<NSString*, NSString*>* environment =
|
|
246
|
+
[NSProcessInfo.processInfo.environment mutableCopy];
|
|
247
|
+
for (NSString* key in @[
|
|
248
|
+
@"CODEX_CI",
|
|
249
|
+
@"CODEX_INTERNAL_ORIGINATOR_OVERRIDE",
|
|
250
|
+
@"CODEX_SESSION_ID",
|
|
251
|
+
@"CODEX_SHELL",
|
|
252
|
+
@"CODEX_THREAD_ID",
|
|
253
|
+
]) {
|
|
254
|
+
[environment removeObjectForKey:key];
|
|
255
|
+
}
|
|
256
|
+
environment[@"CODEX_CLI_AUTH_CREDENTIALS_STORE"] = @"file";
|
|
257
|
+
environment[@"CODEX_HOME"] = isolatedCodexHome();
|
|
258
|
+
return environment;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
NSString* defaultWorkingDirectory() {
|
|
262
|
+
NSString* path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"legend-codex-workspace"];
|
|
263
|
+
NSError* error = nil;
|
|
264
|
+
if ([[NSFileManager defaultManager] createDirectoryAtPath:path
|
|
265
|
+
withIntermediateDirectories:YES
|
|
266
|
+
attributes:nil
|
|
267
|
+
error:&error]) {
|
|
268
|
+
return path;
|
|
269
|
+
}
|
|
270
|
+
return NSTemporaryDirectory();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
std::vector<char*> pointerArray(std::vector<std::string>& values) {
|
|
274
|
+
std::vector<char*> pointers;
|
|
275
|
+
pointers.reserve(values.size() + 1);
|
|
276
|
+
for (std::string& value : values) {
|
|
277
|
+
pointers.push_back(value.data());
|
|
278
|
+
}
|
|
279
|
+
pointers.push_back(nullptr);
|
|
280
|
+
return pointers;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
struct TurnState {
|
|
284
|
+
std::string error;
|
|
285
|
+
std::string output;
|
|
286
|
+
std::string threadId;
|
|
287
|
+
bool done = false;
|
|
288
|
+
bool acknowledged = false;
|
|
289
|
+
uint64_t sequence = 0;
|
|
290
|
+
size_t preAckBytes = 0;
|
|
291
|
+
bool preAckLimitExceeded = false;
|
|
292
|
+
};
|
|
293
|
+
// Turn ids are only unique within one app-server process, so turn state is keyed by process generation.
|
|
294
|
+
using TurnKey = std::pair<uint64_t, std::string>;
|
|
295
|
+
|
|
296
|
+
class CodexProcessSupervisor {
|
|
297
|
+
public:
|
|
298
|
+
static CodexProcessSupervisor& shared() {
|
|
299
|
+
static CodexProcessSupervisor* supervisor = new CodexProcessSupervisor();
|
|
300
|
+
return *supervisor;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
CodexAvailability getAvailability() {
|
|
304
|
+
@autoreleasepool {
|
|
305
|
+
const std::string path = resolveCodexPath();
|
|
306
|
+
if (path.empty()) {
|
|
307
|
+
return CodexAvailability(
|
|
308
|
+
false,
|
|
309
|
+
"",
|
|
310
|
+
"Codex CLI was not found. Install Codex, or set CODEX_PATH to the Codex executable, then reopen the app.",
|
|
311
|
+
"");
|
|
312
|
+
}
|
|
313
|
+
{
|
|
314
|
+
std::lock_guard lock(mutex_);
|
|
315
|
+
if (useExecFallback_) {
|
|
316
|
+
return CodexAvailability(
|
|
317
|
+
true,
|
|
318
|
+
path,
|
|
319
|
+
"Codex is ready in compatibility mode.",
|
|
320
|
+
userAgent_);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
ensureInitialized();
|
|
325
|
+
std::lock_guard lock(mutex_);
|
|
326
|
+
return CodexAvailability(true, codexPath_, "Codex is ready.", userAgent_);
|
|
327
|
+
} catch (const std::exception& error) {
|
|
328
|
+
return CodexAvailability(false, path, actionableError(error.what()), "");
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
CodexRunResult runPrompt(
|
|
334
|
+
const std::string& prompt,
|
|
335
|
+
const std::string& cwd,
|
|
336
|
+
const std::string& reasoningEffort,
|
|
337
|
+
double timeoutMs,
|
|
338
|
+
const std::string& outputSchemaJson,
|
|
339
|
+
const std::string& developerInstructions) {
|
|
340
|
+
@autoreleasepool {
|
|
341
|
+
if (prompt.empty()) {
|
|
342
|
+
throw std::runtime_error("Enter a prompt before running Codex.");
|
|
343
|
+
}
|
|
344
|
+
if (!std::isfinite(timeoutMs) || std::floor(timeoutMs) != timeoutMs || timeoutMs < 1'000 || timeoutMs > kMaximumRunTimeoutMs) {
|
|
345
|
+
throw std::runtime_error("Codex timeout must be a whole number from 1000 to 86400000 milliseconds.");
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
uint64_t acceptedCancellationGeneration = 0;
|
|
349
|
+
{
|
|
350
|
+
std::lock_guard lock(mutex_);
|
|
351
|
+
acceptedCancellationGeneration = cancelGeneration_;
|
|
352
|
+
++activeRuns_;
|
|
353
|
+
}
|
|
354
|
+
struct RunGuard {
|
|
355
|
+
CodexProcessSupervisor* owner;
|
|
356
|
+
~RunGuard() {
|
|
357
|
+
std::lock_guard lock(owner->mutex_);
|
|
358
|
+
// Turns left from ended processes can only be claimed by an active run.
|
|
359
|
+
if (--owner->activeRuns_ == 0) std::erase_if(owner->turns_, [&](const auto& turn) { return turn.first.first != owner->processGeneration_; });
|
|
360
|
+
owner->condition_.notify_all();
|
|
361
|
+
}
|
|
362
|
+
} runGuard{this};
|
|
363
|
+
auto throwIfCancelled = [&]() {
|
|
364
|
+
std::lock_guard lock(mutex_);
|
|
365
|
+
if (cancelGeneration_ != acceptedCancellationGeneration) throw std::runtime_error("Codex request was cancelled.");
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const auto deadline = Clock::now() + std::chrono::milliseconds(static_cast<int64_t>(timeoutMs));
|
|
369
|
+
NSString* requestedCwd = cwd.empty() ? defaultWorkingDirectory() : toNSString(cwd);
|
|
370
|
+
BOOL isDirectory = NO;
|
|
371
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:requestedCwd isDirectory:&isDirectory] || !isDirectory) {
|
|
372
|
+
throw std::runtime_error("Codex working directory does not exist: " + toString(requestedCwd));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
bool useExecFallback = false;
|
|
376
|
+
{
|
|
377
|
+
std::lock_guard lock(mutex_);
|
|
378
|
+
useExecFallback = useExecFallback_;
|
|
379
|
+
}
|
|
380
|
+
if (useExecFallback) {
|
|
381
|
+
throwIfCancelled();
|
|
382
|
+
return runExecFallback(
|
|
383
|
+
prompt,
|
|
384
|
+
requestedCwd,
|
|
385
|
+
reasoningEffort,
|
|
386
|
+
outputSchemaJson,
|
|
387
|
+
developerInstructions,
|
|
388
|
+
acceptedCancellationGeneration,
|
|
389
|
+
std::min(deadline, Clock::now() + std::chrono::seconds(20)));
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
try { ensureInitialized(acceptedCancellationGeneration, deadline); } catch (...) { throwIfCancelled(); throw; }
|
|
393
|
+
throwIfCancelled();
|
|
394
|
+
uint64_t runProcessGeneration = 0;
|
|
395
|
+
{ std::lock_guard lock(mutex_); runProcessGeneration = processGeneration_; }
|
|
396
|
+
if (runProcessGeneration == 0) throw std::runtime_error("Codex app-server is not running.");
|
|
397
|
+
|
|
398
|
+
NSMutableDictionary* threadParams = [@{
|
|
399
|
+
@"approvalPolicy": @"never",
|
|
400
|
+
@"config": @{
|
|
401
|
+
@"cli_auth_credentials_store": @"file",
|
|
402
|
+
@"features": @{
|
|
403
|
+
@"apps": @NO,
|
|
404
|
+
@"plugins": @NO,
|
|
405
|
+
@"remote_plugin": @NO,
|
|
406
|
+
@"shell_snapshot": @NO,
|
|
407
|
+
@"shell_tool": @NO,
|
|
408
|
+
},
|
|
409
|
+
@"mcp_servers": @{},
|
|
410
|
+
@"orchestrator": @{
|
|
411
|
+
@"mcp": @{
|
|
412
|
+
@"enabled": @NO,
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
@"cwd": requestedCwd,
|
|
417
|
+
@"ephemeral": @YES,
|
|
418
|
+
@"sandbox": @"read-only",
|
|
419
|
+
} mutableCopy];
|
|
420
|
+
if (!developerInstructions.empty()) {
|
|
421
|
+
threadParams[@"developerInstructions"] = toNSString(developerInstructions);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
NSDictionary* threadResponse = nil;
|
|
425
|
+
try {
|
|
426
|
+
const auto threadDeadline = std::min(deadline, Clock::now() + std::chrono::seconds(5));
|
|
427
|
+
threadResponse = request(@"thread/start", threadParams, threadDeadline, acceptedCancellationGeneration, runProcessGeneration);
|
|
428
|
+
} catch (const std::exception& error) {
|
|
429
|
+
throwIfCancelled();
|
|
430
|
+
if (!containsInsensitive(error.what(), "did not respond in time")) {
|
|
431
|
+
throw;
|
|
432
|
+
}
|
|
433
|
+
{
|
|
434
|
+
std::lock_guard lock(mutex_);
|
|
435
|
+
if (processGeneration_ != runProcessGeneration) throw std::runtime_error("Codex app-server restarted during thread startup.");
|
|
436
|
+
useExecFallback_ = true;
|
|
437
|
+
}
|
|
438
|
+
terminateProcessGeneration(runProcessGeneration, "Codex app-server did not respond during thread startup.");
|
|
439
|
+
return runExecFallback(
|
|
440
|
+
prompt,
|
|
441
|
+
requestedCwd,
|
|
442
|
+
reasoningEffort,
|
|
443
|
+
outputSchemaJson,
|
|
444
|
+
developerInstructions,
|
|
445
|
+
acceptedCancellationGeneration,
|
|
446
|
+
std::min(deadline, Clock::now() + std::chrono::seconds(20)));
|
|
447
|
+
}
|
|
448
|
+
throwIfCancelled();
|
|
449
|
+
throwForResponseError(threadResponse, "Codex could not start a thread");
|
|
450
|
+
NSDictionary* threadResult = dictionaryValue(threadResponse[@"result"]);
|
|
451
|
+
NSDictionary* thread = dictionaryValue(threadResult[@"thread"]);
|
|
452
|
+
std::string threadId = toString(stringValue(thread[@"id"]));
|
|
453
|
+
std::string model = toString(stringValue(threadResult[@"model"]));
|
|
454
|
+
if (threadId.empty()) {
|
|
455
|
+
throw std::runtime_error(
|
|
456
|
+
"Codex app-server returned an invalid thread response. Update Codex, then reopen the app.");
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
NSMutableDictionary* turnParams = [@{
|
|
460
|
+
@"effort": toNSString(reasoningEffort),
|
|
461
|
+
@"input": @[@{
|
|
462
|
+
@"text": toNSString(prompt),
|
|
463
|
+
@"text_elements": @[],
|
|
464
|
+
@"type": @"text",
|
|
465
|
+
}],
|
|
466
|
+
@"threadId": toNSString(threadId),
|
|
467
|
+
} mutableCopy];
|
|
468
|
+
if (!outputSchemaJson.empty()) {
|
|
469
|
+
NSDictionary* schema = parseJsonObject(outputSchemaJson, "Invalid Codex output schema");
|
|
470
|
+
turnParams[@"outputSchema"] = schema;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
{
|
|
474
|
+
std::lock_guard lock(mutex_);
|
|
475
|
+
if (processGeneration_ != runProcessGeneration) throw std::runtime_error("Codex app-server restarted before turn startup.");
|
|
476
|
+
++pendingTurnStarts_;
|
|
477
|
+
}
|
|
478
|
+
bool pendingTurnStart = true;
|
|
479
|
+
auto finishPendingTurnStart = [&]() {
|
|
480
|
+
if (!pendingTurnStart) return;
|
|
481
|
+
std::lock_guard lock(mutex_);
|
|
482
|
+
if (processGeneration_ == runProcessGeneration && pendingTurnStarts_ > 0) --pendingTurnStarts_;
|
|
483
|
+
pendingTurnStart = false;
|
|
484
|
+
};
|
|
485
|
+
std::string turnId;
|
|
486
|
+
uint64_t cancelGeneration = acceptedCancellationGeneration;
|
|
487
|
+
try {
|
|
488
|
+
NSDictionary* turnResponse = request(@"turn/start", turnParams, deadline, acceptedCancellationGeneration, runProcessGeneration);
|
|
489
|
+
#if defined(SPARK_CODEX_TESTING)
|
|
490
|
+
if (const char* accept = std::getenv("CODEX_TEST_ACCEPT_TURN_AFTER_EXIT")) {
|
|
491
|
+
// "next" also waits for a later process to start and end.
|
|
492
|
+
const bool next = std::string(accept) == "next";
|
|
493
|
+
std::unique_lock lock(mutex_);
|
|
494
|
+
condition_.wait_until(lock, deadline, [&]() {
|
|
495
|
+
return processGeneration_ != runProcessGeneration && (!next || (processGeneration_ == 0 && nextProcessGeneration_ > runProcessGeneration));
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
#endif
|
|
499
|
+
throwIfCancelled();
|
|
500
|
+
throwForResponseError(turnResponse, "Codex could not start a turn");
|
|
501
|
+
NSDictionary* turnResult = dictionaryValue(turnResponse[@"result"]);
|
|
502
|
+
NSDictionary* turn = dictionaryValue(turnResult[@"turn"]);
|
|
503
|
+
turnId = toString(stringValue(turn[@"id"]));
|
|
504
|
+
if (turnId.empty()) {
|
|
505
|
+
throw std::runtime_error(
|
|
506
|
+
"Codex app-server returned an invalid turn response. Update Codex, then reopen the app.");
|
|
507
|
+
}
|
|
508
|
+
std::lock_guard lock(mutex_);
|
|
509
|
+
auto accepted = turns_.find({runProcessGeneration, turnId});
|
|
510
|
+
if (accepted == turns_.end()) {
|
|
511
|
+
// An ended process keeps the turns it reported; without one, nothing can finish this turn.
|
|
512
|
+
if (processGeneration_ != runProcessGeneration) throw std::runtime_error("Codex app-server restarted before the turn was accepted.");
|
|
513
|
+
accepted = turns_.emplace(TurnKey{runProcessGeneration, turnId}, TurnState()).first;
|
|
514
|
+
}
|
|
515
|
+
TurnState& state = accepted->second;
|
|
516
|
+
state.threadId = threadId;
|
|
517
|
+
preAckBytes_ -= state.preAckBytes;
|
|
518
|
+
state.preAckBytes = 0;
|
|
519
|
+
state.acknowledged = true;
|
|
520
|
+
if (processGeneration_ == runProcessGeneration) --pendingTurnStarts_;
|
|
521
|
+
pendingTurnStart = false;
|
|
522
|
+
} catch (...) {
|
|
523
|
+
finishPendingTurnStart();
|
|
524
|
+
throwIfCancelled();
|
|
525
|
+
throw;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
TurnState completed;
|
|
529
|
+
{
|
|
530
|
+
// Ending a process finishes its turns (completed ones keep their result), so `done` covers exits too.
|
|
531
|
+
const TurnKey key{runProcessGeneration, turnId};
|
|
532
|
+
std::unique_lock lock(mutex_);
|
|
533
|
+
condition_.wait_until(lock, deadline, [&]() {
|
|
534
|
+
const auto state = turns_.find(key);
|
|
535
|
+
return cancelGeneration_ != cancelGeneration || (state != turns_.end() && state->second.done);
|
|
536
|
+
});
|
|
537
|
+
if (const auto state = turns_.find(key); state != turns_.end()) {
|
|
538
|
+
completed = std::move(state->second);
|
|
539
|
+
turns_.erase(state);
|
|
540
|
+
}
|
|
541
|
+
retireTurnLocked(runProcessGeneration, turnId);
|
|
542
|
+
if (cancelGeneration_ != cancelGeneration) {
|
|
543
|
+
throw std::runtime_error("Codex request was cancelled.");
|
|
544
|
+
} else if (!completed.done) {
|
|
545
|
+
lock.unlock();
|
|
546
|
+
interruptTurn(threadId, turnId, runProcessGeneration);
|
|
547
|
+
const int seconds = static_cast<int>(timeoutMs / 1000.0);
|
|
548
|
+
throw std::runtime_error(
|
|
549
|
+
"Codex did not finish within " + std::to_string(seconds) +
|
|
550
|
+
" seconds. Try a shorter prompt; if Codex is also stuck in Terminal, run `codex login`.");
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if (!completed.error.empty()) {
|
|
555
|
+
throw std::runtime_error(actionableError(completed.error));
|
|
556
|
+
}
|
|
557
|
+
if (completed.preAckLimitExceeded) {
|
|
558
|
+
throw std::runtime_error("Codex app-server response exceeded the 16 MiB pre-ack notification limit.");
|
|
559
|
+
}
|
|
560
|
+
if (completed.output.empty()) {
|
|
561
|
+
throw std::runtime_error(
|
|
562
|
+
"Codex completed without a response. Try again; if it keeps happening, update Codex and reopen the app.");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
std::lock_guard lock(mutex_);
|
|
566
|
+
return CodexRunResult(model, completed.output, threadId, turnId, userAgent_);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
double cancelActiveRuns() {
|
|
571
|
+
pid_t serverPid = -1;
|
|
572
|
+
uint64_t serverGeneration = 0;
|
|
573
|
+
size_t acceptedRuns = 0;
|
|
574
|
+
std::vector<pid_t> fallbackPids;
|
|
575
|
+
{
|
|
576
|
+
std::lock_guard lock(mutex_);
|
|
577
|
+
++cancelGeneration_;
|
|
578
|
+
acceptedRuns = activeRuns_;
|
|
579
|
+
serverPid = activeRuns_ > 0 ? pid_ : -1;
|
|
580
|
+
serverGeneration = activeRuns_ > 0 ? processGeneration_ : 0;
|
|
581
|
+
fallbackPids.assign(fallbackPids_.begin(), fallbackPids_.end());
|
|
582
|
+
condition_.notify_all();
|
|
583
|
+
}
|
|
584
|
+
if (serverGeneration > 0) terminateProcessGeneration(serverGeneration, "Codex request was cancelled.");
|
|
585
|
+
else if (serverPid > 0) kill(-serverPid, SIGTERM);
|
|
586
|
+
for (pid_t pid : fallbackPids) {
|
|
587
|
+
kill(pid, SIGTERM);
|
|
588
|
+
}
|
|
589
|
+
return static_cast<double>(acceptedRuns);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
double shutdown() {
|
|
593
|
+
std::lock_guard lifecycleLock(lifecycleMutex_);
|
|
594
|
+
pid_t pid = -1;
|
|
595
|
+
int stdinFd = -1;
|
|
596
|
+
std::vector<pid_t> fallbackPids;
|
|
597
|
+
{
|
|
598
|
+
std::lock_guard lock(mutex_);
|
|
599
|
+
++cancelGeneration_;
|
|
600
|
+
pid = pid_;
|
|
601
|
+
stdinFd = stdinFd_;
|
|
602
|
+
pid_ = -1;
|
|
603
|
+
stdinFd_ = -1;
|
|
604
|
+
initialized_ = false;
|
|
605
|
+
processError_ = "Codex app-server was stopped.";
|
|
606
|
+
endGenerationLocked(processGeneration_, processError_);
|
|
607
|
+
fallbackPids.assign(fallbackPids_.begin(), fallbackPids_.end());
|
|
608
|
+
fallbackPids_.clear();
|
|
609
|
+
useExecFallback_ = false;
|
|
610
|
+
}
|
|
611
|
+
if (stdinFd >= 0) {
|
|
612
|
+
close(stdinFd);
|
|
613
|
+
}
|
|
614
|
+
if (pid > 0) {
|
|
615
|
+
kill(-pid, SIGTERM);
|
|
616
|
+
}
|
|
617
|
+
for (pid_t fallbackPid : fallbackPids) {
|
|
618
|
+
kill(fallbackPid, SIGTERM);
|
|
619
|
+
}
|
|
620
|
+
return static_cast<double>((pid > 0 ? 1 : 0) + fallbackPids.size());
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
#if defined(SPARK_CODEX_TESTING)
|
|
624
|
+
size_t retainedTurnCountForTesting() {
|
|
625
|
+
std::lock_guard lock(mutex_);
|
|
626
|
+
return turns_.size();
|
|
627
|
+
}
|
|
628
|
+
size_t blockedWriteCountForTesting() {
|
|
629
|
+
std::lock_guard lock(mutex_);
|
|
630
|
+
return blockedWriteCount_;
|
|
631
|
+
}
|
|
632
|
+
#endif
|
|
633
|
+
|
|
634
|
+
private:
|
|
635
|
+
// Ends a process generation without discarding its turns: completed turns keep their result for the run
|
|
636
|
+
// that collects them, and unfinished turns fail with the reason.
|
|
637
|
+
void endGenerationLocked(uint64_t generation, const std::string& reason) {
|
|
638
|
+
processGeneration_ = 0;
|
|
639
|
+
for (auto& [key, state] : turns_) {
|
|
640
|
+
if (key.first != generation) continue;
|
|
641
|
+
preAckBytes_ -= state.preAckBytes;
|
|
642
|
+
state.preAckBytes = 0;
|
|
643
|
+
if (!state.done) {
|
|
644
|
+
state.error = reason;
|
|
645
|
+
state.done = true;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
pendingTurnStarts_ = 0;
|
|
649
|
+
condition_.notify_all();
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
void retireTurnLocked(uint64_t generation, const std::string& turnId) {
|
|
653
|
+
if (generation != processGeneration_ || turnId.empty() || !retiredTurnIds_.insert(turnId).second) return;
|
|
654
|
+
retiredTurnOrder_.push_back(turnId);
|
|
655
|
+
while (retiredTurnOrder_.size() > 512) {
|
|
656
|
+
retiredTurnIds_.erase(retiredTurnOrder_.front());
|
|
657
|
+
retiredTurnOrder_.pop_front();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
TurnState* pendingOrActiveTurnLocked(uint64_t generation, const std::string& turnId) {
|
|
662
|
+
if (turnId.empty() || retiredTurnIds_.contains(turnId)) return nullptr;
|
|
663
|
+
auto found = turns_.find({generation, turnId});
|
|
664
|
+
if (found != turns_.end()) return &found->second;
|
|
665
|
+
if (pendingTurnStarts_ == 0) return nullptr;
|
|
666
|
+
while (turns_.size() >= 128) {
|
|
667
|
+
auto oldest = turns_.end();
|
|
668
|
+
for (auto it = turns_.begin(); it != turns_.end(); ++it) {
|
|
669
|
+
if (!it->second.acknowledged && (oldest == turns_.end() || it->second.sequence < oldest->second.sequence)) oldest = it;
|
|
670
|
+
}
|
|
671
|
+
if (oldest == turns_.end()) return nullptr;
|
|
672
|
+
preAckBytes_ -= oldest->second.preAckBytes;
|
|
673
|
+
turns_.erase(oldest);
|
|
674
|
+
}
|
|
675
|
+
TurnState state;
|
|
676
|
+
state.sequence = ++nextTurnSequence_;
|
|
677
|
+
return &turns_.emplace(TurnKey{generation, turnId}, std::move(state)).first->second;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
void setPreAckTextLocked(TurnState& state, std::string TurnState::*field, const std::string& value) {
|
|
681
|
+
std::string& current = state.*field;
|
|
682
|
+
if (state.acknowledged) { current = value; return; }
|
|
683
|
+
if (state.preAckLimitExceeded) return;
|
|
684
|
+
const size_t nextTotal = preAckBytes_ - current.size() + value.size();
|
|
685
|
+
if (nextTotal > kMaximumPreAckBytes) {
|
|
686
|
+
preAckBytes_ -= state.preAckBytes;
|
|
687
|
+
state.preAckBytes = 0;
|
|
688
|
+
state.output.clear();
|
|
689
|
+
state.error.clear();
|
|
690
|
+
state.preAckLimitExceeded = true;
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
preAckBytes_ = nextTotal;
|
|
694
|
+
state.preAckBytes = state.preAckBytes - current.size() + value.size();
|
|
695
|
+
current = value;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
CodexRunResult runExecFallback(
|
|
699
|
+
const std::string& prompt,
|
|
700
|
+
NSString* requestedCwd,
|
|
701
|
+
const std::string& reasoningEffort,
|
|
702
|
+
const std::string& outputSchemaJson,
|
|
703
|
+
const std::string& developerInstructions,
|
|
704
|
+
uint64_t acceptedCancellationGeneration,
|
|
705
|
+
Clock::time_point deadline) {
|
|
706
|
+
{ std::lock_guard lock(mutex_); if (cancelGeneration_ != acceptedCancellationGeneration) throw std::runtime_error("Codex request was cancelled."); }
|
|
707
|
+
const std::string codexPath = resolveCodexPath();
|
|
708
|
+
if (codexPath.empty()) {
|
|
709
|
+
throw std::runtime_error(
|
|
710
|
+
"Codex CLI was not found. Install Codex, or set CODEX_PATH to the Codex executable, then reopen the app.");
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
714
|
+
NSString* temporaryDirectory = NSTemporaryDirectory();
|
|
715
|
+
NSString* identifier = NSUUID.UUID.UUIDString;
|
|
716
|
+
NSString* promptPath = [temporaryDirectory
|
|
717
|
+
stringByAppendingPathComponent:[NSString stringWithFormat:@"legend-codex-%@-prompt.txt", identifier]];
|
|
718
|
+
NSString* outputPath = [temporaryDirectory
|
|
719
|
+
stringByAppendingPathComponent:[NSString stringWithFormat:@"legend-codex-%@-output.txt", identifier]];
|
|
720
|
+
NSString* errorPath = [temporaryDirectory
|
|
721
|
+
stringByAppendingPathComponent:[NSString stringWithFormat:@"legend-codex-%@-error.txt", identifier]];
|
|
722
|
+
NSString* schemaPath = outputSchemaJson.empty()
|
|
723
|
+
? nil
|
|
724
|
+
: [temporaryDirectory
|
|
725
|
+
stringByAppendingPathComponent:[NSString stringWithFormat:@"legend-codex-%@-schema.json", identifier]];
|
|
726
|
+
NSArray<NSString*>* temporaryPaths = schemaPath == nil
|
|
727
|
+
? @[promptPath, outputPath, errorPath]
|
|
728
|
+
: @[promptPath, outputPath, errorPath, schemaPath];
|
|
729
|
+
auto cleanup = [&]() {
|
|
730
|
+
for (NSString* path in temporaryPaths) {
|
|
731
|
+
[fileManager removeItemAtPath:path error:nil];
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
std::string combinedPrompt = prompt;
|
|
736
|
+
if (!developerInstructions.empty()) {
|
|
737
|
+
combinedPrompt = developerInstructions + "\n\nUser request:\n" + prompt;
|
|
738
|
+
}
|
|
739
|
+
NSError* fileError = nil;
|
|
740
|
+
if (![toNSString(combinedPrompt) writeToFile:promptPath
|
|
741
|
+
atomically:YES
|
|
742
|
+
encoding:NSUTF8StringEncoding
|
|
743
|
+
error:&fileError]) {
|
|
744
|
+
cleanup();
|
|
745
|
+
throw std::runtime_error(
|
|
746
|
+
"Could not prepare the Codex request: " + toString(fileError.localizedDescription));
|
|
747
|
+
}
|
|
748
|
+
[fileManager createFileAtPath:outputPath contents:nil attributes:nil];
|
|
749
|
+
[fileManager createFileAtPath:errorPath contents:nil attributes:nil];
|
|
750
|
+
|
|
751
|
+
if (schemaPath != nil) {
|
|
752
|
+
parseJsonObject(outputSchemaJson, "Invalid Codex output schema");
|
|
753
|
+
if (![toNSString(outputSchemaJson) writeToFile:schemaPath
|
|
754
|
+
atomically:YES
|
|
755
|
+
encoding:NSUTF8StringEncoding
|
|
756
|
+
error:&fileError]) {
|
|
757
|
+
cleanup();
|
|
758
|
+
throw std::runtime_error(
|
|
759
|
+
"Could not prepare the Codex output schema: " + toString(fileError.localizedDescription));
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
NSMutableArray<NSString*>* arguments = [NSMutableArray arrayWithArray:@[
|
|
764
|
+
@"--ask-for-approval",
|
|
765
|
+
@"never",
|
|
766
|
+
@"exec",
|
|
767
|
+
@"--ephemeral",
|
|
768
|
+
@"--ignore-user-config",
|
|
769
|
+
@"--ignore-rules",
|
|
770
|
+
@"--disable",
|
|
771
|
+
@"apps",
|
|
772
|
+
@"--disable",
|
|
773
|
+
@"plugins",
|
|
774
|
+
@"--disable",
|
|
775
|
+
@"remote_plugin",
|
|
776
|
+
@"--disable",
|
|
777
|
+
@"shell_snapshot",
|
|
778
|
+
@"--disable",
|
|
779
|
+
@"shell_tool",
|
|
780
|
+
@"--skip-git-repo-check",
|
|
781
|
+
@"--color",
|
|
782
|
+
@"never",
|
|
783
|
+
@"--sandbox",
|
|
784
|
+
@"read-only",
|
|
785
|
+
@"--config",
|
|
786
|
+
[NSString stringWithFormat:@"model_reasoning_effort=\"%@\"", toNSString(reasoningEffort)],
|
|
787
|
+
@"--config",
|
|
788
|
+
@"mcp_servers={}",
|
|
789
|
+
@"--config",
|
|
790
|
+
@"orchestrator.mcp.enabled=false",
|
|
791
|
+
@"--config",
|
|
792
|
+
@"cli_auth_credentials_store=\"file\"",
|
|
793
|
+
@"--output-last-message",
|
|
794
|
+
outputPath,
|
|
795
|
+
]];
|
|
796
|
+
if (schemaPath != nil) {
|
|
797
|
+
[arguments addObjectsFromArray:@[@"--output-schema", schemaPath]];
|
|
798
|
+
}
|
|
799
|
+
[arguments addObject:@"-"];
|
|
800
|
+
|
|
801
|
+
NSFileHandle* promptHandle = [NSFileHandle fileHandleForReadingAtPath:promptPath];
|
|
802
|
+
NSFileHandle* errorHandle = [NSFileHandle fileHandleForWritingAtPath:errorPath];
|
|
803
|
+
if (promptHandle == nil || errorHandle == nil) {
|
|
804
|
+
cleanup();
|
|
805
|
+
throw std::runtime_error("Could not open temporary files for the Codex request.");
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
NSTask* task = [NSTask new];
|
|
809
|
+
task.executableURL = [NSURL fileURLWithPath:toNSString(codexPath)];
|
|
810
|
+
task.arguments = arguments;
|
|
811
|
+
task.currentDirectoryURL = [NSURL fileURLWithPath:requestedCwd isDirectory:YES];
|
|
812
|
+
task.environment = sanitizedEnvironmentDictionary();
|
|
813
|
+
task.standardInput = promptHandle;
|
|
814
|
+
task.standardOutput = NSFileHandle.fileHandleWithNullDevice;
|
|
815
|
+
task.standardError = errorHandle;
|
|
816
|
+
|
|
817
|
+
NSError* launchError = nil;
|
|
818
|
+
if (![task launchAndReturnError:&launchError]) {
|
|
819
|
+
[promptHandle closeFile];
|
|
820
|
+
[errorHandle closeFile];
|
|
821
|
+
cleanup();
|
|
822
|
+
throw std::runtime_error(
|
|
823
|
+
actionableError("Could not start Codex: " + toString(launchError.localizedDescription)));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
const pid_t pid = task.processIdentifier;
|
|
827
|
+
{
|
|
828
|
+
std::lock_guard lock(mutex_);
|
|
829
|
+
fallbackPids_.insert(pid);
|
|
830
|
+
if (cancelGeneration_ != acceptedCancellationGeneration) kill(pid, SIGTERM);
|
|
831
|
+
}
|
|
832
|
+
while (task.isRunning && Clock::now() < deadline) {
|
|
833
|
+
{ std::lock_guard lock(mutex_); if (cancelGeneration_ != acceptedCancellationGeneration) break; }
|
|
834
|
+
usleep(10'000);
|
|
835
|
+
}
|
|
836
|
+
if (task.isRunning) {
|
|
837
|
+
[task terminate];
|
|
838
|
+
const auto terminationDeadline = Clock::now() + std::chrono::seconds(1);
|
|
839
|
+
while (task.isRunning && Clock::now() < terminationDeadline) {
|
|
840
|
+
usleep(10'000);
|
|
841
|
+
}
|
|
842
|
+
if (task.isRunning) {
|
|
843
|
+
kill(pid, SIGKILL);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
[task waitUntilExit];
|
|
847
|
+
[promptHandle closeFile];
|
|
848
|
+
[errorHandle closeFile];
|
|
849
|
+
{
|
|
850
|
+
std::lock_guard lock(mutex_);
|
|
851
|
+
fallbackPids_.erase(pid);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
NSString* output = [NSString stringWithContentsOfFile:outputPath
|
|
855
|
+
encoding:NSUTF8StringEncoding
|
|
856
|
+
error:nil] ?: @"";
|
|
857
|
+
NSString* errorOutput = [NSString stringWithContentsOfFile:errorPath
|
|
858
|
+
encoding:NSUTF8StringEncoding
|
|
859
|
+
error:nil] ?: @"";
|
|
860
|
+
cleanup();
|
|
861
|
+
|
|
862
|
+
{
|
|
863
|
+
std::lock_guard lock(mutex_);
|
|
864
|
+
if (cancelGeneration_ != acceptedCancellationGeneration) {
|
|
865
|
+
throw std::runtime_error("Codex request was cancelled.");
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (Clock::now() >= deadline) {
|
|
869
|
+
throw std::runtime_error(
|
|
870
|
+
"Codex could not start from this app. In Terminal, run `codex login status`, then "
|
|
871
|
+
"`codex exec \"Reply with ok\"`. If both work, update Codex and reopen this app; "
|
|
872
|
+
"your Codex version has a background-process startup issue.");
|
|
873
|
+
}
|
|
874
|
+
if (task.terminationStatus != 0) {
|
|
875
|
+
std::string detail = toString([errorOutput stringByTrimmingCharactersInSet:
|
|
876
|
+
NSCharacterSet.whitespaceAndNewlineCharacterSet]);
|
|
877
|
+
if (detail.empty()) {
|
|
878
|
+
detail = "Codex exited with status " + std::to_string(task.terminationStatus) + ".";
|
|
879
|
+
}
|
|
880
|
+
throw std::runtime_error(actionableError("Codex could not generate suggestions: " + detail));
|
|
881
|
+
}
|
|
882
|
+
std::string result = toString([output stringByTrimmingCharactersInSet:
|
|
883
|
+
NSCharacterSet.whitespaceAndNewlineCharacterSet]);
|
|
884
|
+
if (result.empty()) {
|
|
885
|
+
throw std::runtime_error(
|
|
886
|
+
"Codex completed without a response. Try again; if it keeps happening, update Codex and reopen the app.");
|
|
887
|
+
}
|
|
888
|
+
std::lock_guard lock(mutex_);
|
|
889
|
+
return CodexRunResult("", result, "", "", userAgent_);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
void ensureInitialized(uint64_t cancellationGeneration = UINT64_MAX, Clock::time_point runDeadline = Clock::time_point::max()) {
|
|
893
|
+
const auto initializeDeadline = std::min(runDeadline, Clock::now() + std::chrono::milliseconds(static_cast<int64_t>(kInitializeTimeoutMs)));
|
|
894
|
+
std::unique_lock lifecycleLock(lifecycleMutex_, std::defer_lock);
|
|
895
|
+
while (!lifecycleLock.try_lock_for(std::chrono::milliseconds(10))) {
|
|
896
|
+
std::lock_guard lock(mutex_);
|
|
897
|
+
if (cancellationGeneration != UINT64_MAX && cancelGeneration_ != cancellationGeneration) throw std::runtime_error("Codex request was cancelled.");
|
|
898
|
+
if (Clock::now() >= initializeDeadline) throw std::runtime_error("Codex app-server did not respond in time.");
|
|
899
|
+
}
|
|
900
|
+
{
|
|
901
|
+
std::lock_guard lock(mutex_);
|
|
902
|
+
if (initialized_ && pid_ > 0) {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
startProcess();
|
|
907
|
+
try {
|
|
908
|
+
const auto deadline = initializeDeadline;
|
|
909
|
+
NSDictionary* response = request(@"initialize", @{
|
|
910
|
+
@"capabilities": @{
|
|
911
|
+
@"experimentalApi": @NO,
|
|
912
|
+
@"optOutNotificationMethods": @[
|
|
913
|
+
@"account/rateLimits/updated",
|
|
914
|
+
@"item/agentMessage/delta",
|
|
915
|
+
@"item/started",
|
|
916
|
+
@"mcpServer/startupStatus/updated",
|
|
917
|
+
@"thread/started",
|
|
918
|
+
@"thread/status/changed",
|
|
919
|
+
@"thread/tokenUsage/updated",
|
|
920
|
+
@"turn/started",
|
|
921
|
+
],
|
|
922
|
+
@"requestAttestation": @NO,
|
|
923
|
+
},
|
|
924
|
+
@"clientInfo": @{
|
|
925
|
+
@"name": @"legend-apps",
|
|
926
|
+
@"title": @"Legend Apps",
|
|
927
|
+
@"version": @"0.0.1",
|
|
928
|
+
},
|
|
929
|
+
}, deadline, cancellationGeneration);
|
|
930
|
+
throwForResponseError(response, "Codex app-server could not initialize");
|
|
931
|
+
NSDictionary* result = dictionaryValue(response[@"result"]);
|
|
932
|
+
std::string userAgent = toString(stringValue(result[@"userAgent"]));
|
|
933
|
+
if (userAgent.empty()) {
|
|
934
|
+
throw std::runtime_error(
|
|
935
|
+
"Codex app-server returned an invalid initialize response. Update Codex, then reopen the app.");
|
|
936
|
+
}
|
|
937
|
+
sendNotification(@"initialized", cancellationGeneration, deadline);
|
|
938
|
+
{
|
|
939
|
+
std::lock_guard lock(mutex_);
|
|
940
|
+
userAgent_ = userAgent;
|
|
941
|
+
initialized_ = true;
|
|
942
|
+
}
|
|
943
|
+
} catch (...) {
|
|
944
|
+
terminateCurrentProcess();
|
|
945
|
+
throw;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
void startProcess() {
|
|
950
|
+
terminateCurrentProcess();
|
|
951
|
+
const std::string codexPath = resolveCodexPath();
|
|
952
|
+
if (codexPath.empty()) {
|
|
953
|
+
throw std::runtime_error(
|
|
954
|
+
"Codex CLI was not found. Install Codex, or set CODEX_PATH to the Codex executable, then reopen the app.");
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
int inputPipe[2] = {-1, -1};
|
|
958
|
+
int outputPipe[2] = {-1, -1};
|
|
959
|
+
int errorPipe[2] = {-1, -1};
|
|
960
|
+
if (pipe(inputPipe) != 0 || pipe(outputPipe) != 0 || pipe(errorPipe) != 0) {
|
|
961
|
+
closePipe(inputPipe);
|
|
962
|
+
closePipe(outputPipe);
|
|
963
|
+
closePipe(errorPipe);
|
|
964
|
+
throw std::runtime_error("Could not create pipes for Codex app-server: " + std::string(strerror(errno)));
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
posix_spawn_file_actions_t actions;
|
|
968
|
+
posix_spawn_file_actions_init(&actions);
|
|
969
|
+
posix_spawn_file_actions_adddup2(&actions, inputPipe[0], STDIN_FILENO);
|
|
970
|
+
posix_spawn_file_actions_adddup2(&actions, outputPipe[1], STDOUT_FILENO);
|
|
971
|
+
posix_spawn_file_actions_adddup2(&actions, errorPipe[1], STDERR_FILENO);
|
|
972
|
+
posix_spawn_file_actions_addclose(&actions, inputPipe[0]);
|
|
973
|
+
posix_spawn_file_actions_addclose(&actions, inputPipe[1]);
|
|
974
|
+
posix_spawn_file_actions_addclose(&actions, outputPipe[0]);
|
|
975
|
+
posix_spawn_file_actions_addclose(&actions, outputPipe[1]);
|
|
976
|
+
posix_spawn_file_actions_addclose(&actions, errorPipe[0]);
|
|
977
|
+
posix_spawn_file_actions_addclose(&actions, errorPipe[1]);
|
|
978
|
+
#if defined(__APPLE__)
|
|
979
|
+
posix_spawn_file_actions_addchdir_np(&actions, defaultWorkingDirectory().fileSystemRepresentation);
|
|
980
|
+
#endif
|
|
981
|
+
|
|
982
|
+
posix_spawnattr_t attributes;
|
|
983
|
+
posix_spawnattr_init(&attributes);
|
|
984
|
+
short spawnFlags = 0;
|
|
985
|
+
#if defined(__APPLE__) && defined(POSIX_SPAWN_CLOEXEC_DEFAULT)
|
|
986
|
+
spawnFlags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
|
|
987
|
+
#endif
|
|
988
|
+
sigset_t emptySignalMask;
|
|
989
|
+
sigemptyset(&emptySignalMask);
|
|
990
|
+
posix_spawnattr_setsigmask(&attributes, &emptySignalMask);
|
|
991
|
+
spawnFlags |= POSIX_SPAWN_SETSIGMASK;
|
|
992
|
+
|
|
993
|
+
sigset_t defaultSignals;
|
|
994
|
+
sigfillset(&defaultSignals);
|
|
995
|
+
sigdelset(&defaultSignals, SIGKILL);
|
|
996
|
+
sigdelset(&defaultSignals, SIGSTOP);
|
|
997
|
+
posix_spawnattr_setsigdefault(&attributes, &defaultSignals);
|
|
998
|
+
spawnFlags |= POSIX_SPAWN_SETSIGDEF;
|
|
999
|
+
posix_spawnattr_setpgroup(&attributes, 0);
|
|
1000
|
+
spawnFlags |= POSIX_SPAWN_SETPGROUP;
|
|
1001
|
+
posix_spawnattr_setflags(&attributes, spawnFlags);
|
|
1002
|
+
|
|
1003
|
+
std::vector<std::string> arguments = {codexPath, "app-server", "--stdio"};
|
|
1004
|
+
std::vector<char*> argumentPointers = pointerArray(arguments);
|
|
1005
|
+
std::vector<std::string> environment = sanitizedEnvironmentStorage();
|
|
1006
|
+
std::vector<char*> environmentPointers = pointerArray(environment);
|
|
1007
|
+
pid_t pid = -1;
|
|
1008
|
+
const int spawnError = posix_spawn(
|
|
1009
|
+
&pid,
|
|
1010
|
+
codexPath.c_str(),
|
|
1011
|
+
&actions,
|
|
1012
|
+
&attributes,
|
|
1013
|
+
argumentPointers.data(),
|
|
1014
|
+
environmentPointers.data());
|
|
1015
|
+
posix_spawnattr_destroy(&attributes);
|
|
1016
|
+
posix_spawn_file_actions_destroy(&actions);
|
|
1017
|
+
close(inputPipe[0]);
|
|
1018
|
+
close(outputPipe[1]);
|
|
1019
|
+
close(errorPipe[1]);
|
|
1020
|
+
if (spawnError != 0) {
|
|
1021
|
+
close(inputPipe[1]);
|
|
1022
|
+
close(outputPipe[0]);
|
|
1023
|
+
close(errorPipe[0]);
|
|
1024
|
+
throw std::runtime_error("Could not start Codex app-server: " + std::string(strerror(spawnError)));
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
#if defined(F_SETNOSIGPIPE)
|
|
1028
|
+
fcntl(inputPipe[1], F_SETNOSIGPIPE, 1);
|
|
1029
|
+
#endif
|
|
1030
|
+
const int inputFlags = fcntl(inputPipe[1], F_GETFL, 0);
|
|
1031
|
+
if (inputFlags >= 0) fcntl(inputPipe[1], F_SETFL, inputFlags | O_NONBLOCK);
|
|
1032
|
+
uint64_t generation = 0;
|
|
1033
|
+
{
|
|
1034
|
+
std::lock_guard lock(mutex_);
|
|
1035
|
+
generation = ++nextProcessGeneration_;
|
|
1036
|
+
processGeneration_ = generation;
|
|
1037
|
+
pid_ = pid;
|
|
1038
|
+
stdinFd_ = inputPipe[1];
|
|
1039
|
+
initialized_ = false;
|
|
1040
|
+
codexPath_ = codexPath;
|
|
1041
|
+
userAgent_.clear();
|
|
1042
|
+
processError_.clear();
|
|
1043
|
+
stderrTail_.clear();
|
|
1044
|
+
ignoredResponseIds_.clear();
|
|
1045
|
+
retiredTurnIds_.clear();
|
|
1046
|
+
retiredTurnOrder_.clear();
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
std::thread([this, fd = errorPipe[0], generation]() { readStderr(fd, generation); }).detach();
|
|
1050
|
+
std::thread([this, pid, generation, outputFd = outputPipe[0]]() {
|
|
1051
|
+
// Handle the exit only after every line the app-server wrote has been handled, so a reply or
|
|
1052
|
+
// turn/completed written just before exiting is never dropped.
|
|
1053
|
+
std::thread reader([this, outputFd, generation]() { readStdout(outputFd, generation); });
|
|
1054
|
+
siginfo_t exited{};
|
|
1055
|
+
while (waitid(P_PID, pid, &exited, WEXITED | WNOWAIT) < 0 && errno == EINTR) {
|
|
1056
|
+
}
|
|
1057
|
+
// Leftover members of the app-server's process group could hold stdout open; the unreaped leader
|
|
1058
|
+
// keeps the group id from being reused.
|
|
1059
|
+
kill(-pid, SIGTERM);
|
|
1060
|
+
reader.join();
|
|
1061
|
+
int status = 0;
|
|
1062
|
+
while (waitpid(pid, &status, 0) < 0 && errno == EINTR) {
|
|
1063
|
+
}
|
|
1064
|
+
processExited(pid, generation, status);
|
|
1065
|
+
}).detach();
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
static void closePipe(int pipeFds[2]) {
|
|
1069
|
+
if (pipeFds[0] >= 0) {
|
|
1070
|
+
close(pipeFds[0]);
|
|
1071
|
+
}
|
|
1072
|
+
if (pipeFds[1] >= 0) {
|
|
1073
|
+
close(pipeFds[1]);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
void terminateCurrentProcess() {
|
|
1078
|
+
pid_t pid = -1;
|
|
1079
|
+
int stdinFd = -1;
|
|
1080
|
+
{
|
|
1081
|
+
std::lock_guard lock(mutex_);
|
|
1082
|
+
pid = pid_;
|
|
1083
|
+
stdinFd = stdinFd_;
|
|
1084
|
+
pid_ = -1;
|
|
1085
|
+
stdinFd_ = -1;
|
|
1086
|
+
initialized_ = false;
|
|
1087
|
+
endGenerationLocked(processGeneration_, "Codex app-server restarted while the request was running.");
|
|
1088
|
+
}
|
|
1089
|
+
if (stdinFd >= 0) {
|
|
1090
|
+
close(stdinFd);
|
|
1091
|
+
}
|
|
1092
|
+
if (pid > 0) {
|
|
1093
|
+
kill(-pid, SIGTERM);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
void terminateProcessGeneration(uint64_t generation, const std::string& reason) {
|
|
1098
|
+
pid_t pid = -1;
|
|
1099
|
+
int stdinFd = -1;
|
|
1100
|
+
{
|
|
1101
|
+
std::lock_guard lock(mutex_);
|
|
1102
|
+
if (processGeneration_ != generation) return;
|
|
1103
|
+
pid = pid_;
|
|
1104
|
+
stdinFd = stdinFd_;
|
|
1105
|
+
pid_ = -1;
|
|
1106
|
+
stdinFd_ = -1;
|
|
1107
|
+
initialized_ = false;
|
|
1108
|
+
processError_ = reason;
|
|
1109
|
+
endGenerationLocked(generation, reason);
|
|
1110
|
+
}
|
|
1111
|
+
if (stdinFd >= 0) close(stdinFd);
|
|
1112
|
+
if (pid > 0) kill(-pid, SIGTERM);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
NSDictionary* request(NSString* method, NSDictionary* params, Clock::time_point deadline, uint64_t cancellationGeneration = UINT64_MAX, uint64_t expectedGeneration = 0) {
|
|
1116
|
+
int64_t requestId = 0;
|
|
1117
|
+
uint64_t generation = 0;
|
|
1118
|
+
{
|
|
1119
|
+
std::lock_guard lock(mutex_);
|
|
1120
|
+
requestId = nextRequestId_++;
|
|
1121
|
+
generation = processGeneration_;
|
|
1122
|
+
if (expectedGeneration != 0 && generation != expectedGeneration) throw std::runtime_error("Codex app-server restarted during the request.");
|
|
1123
|
+
if (generation == 0 || stdinFd_ < 0) {
|
|
1124
|
+
throw std::runtime_error(processError_.empty() ? "Codex app-server is not running." : processError_);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
sendJson(@{
|
|
1129
|
+
@"id": @(requestId),
|
|
1130
|
+
@"method": method,
|
|
1131
|
+
@"params": params,
|
|
1132
|
+
}, generation, cancellationGeneration, deadline);
|
|
1133
|
+
|
|
1134
|
+
std::string responseLine;
|
|
1135
|
+
{
|
|
1136
|
+
std::unique_lock lock(mutex_);
|
|
1137
|
+
const auto cancelled = [&]() { return cancellationGeneration != UINT64_MAX && cancelGeneration_ != cancellationGeneration; };
|
|
1138
|
+
condition_.wait_until(lock, deadline, [&]() {
|
|
1139
|
+
return responses_.contains(requestId) || processGeneration_ != generation || cancelled();
|
|
1140
|
+
});
|
|
1141
|
+
// Responses are keyed by unique request ids and survive restarts; the waiter always removes its own.
|
|
1142
|
+
if (const auto response = responses_.find(requestId); response != responses_.end()) {
|
|
1143
|
+
responseLine = std::move(response->second);
|
|
1144
|
+
responses_.erase(response);
|
|
1145
|
+
} else {
|
|
1146
|
+
ignoredResponseIds_.insert(requestId);
|
|
1147
|
+
}
|
|
1148
|
+
if (cancelled()) throw std::runtime_error("Codex request was cancelled.");
|
|
1149
|
+
if (responseLine.empty() && processGeneration_ == generation) throw std::runtime_error("Codex app-server did not respond in time.");
|
|
1150
|
+
if (responseLine.empty()) throw std::runtime_error(processError_.empty() ? "Codex app-server exited unexpectedly." : processError_);
|
|
1151
|
+
}
|
|
1152
|
+
return parseJsonObject(responseLine, "Codex app-server returned invalid JSON");
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
void sendNotification(NSString* method, uint64_t cancellationGeneration = UINT64_MAX, Clock::time_point deadline = Clock::time_point::max()) {
|
|
1156
|
+
uint64_t generation = 0;
|
|
1157
|
+
{
|
|
1158
|
+
std::lock_guard lock(mutex_);
|
|
1159
|
+
generation = processGeneration_;
|
|
1160
|
+
}
|
|
1161
|
+
sendJson(@{@"method": method}, generation, cancellationGeneration, deadline);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
void interruptTurn(const std::string& threadId, const std::string& turnId, uint64_t expectedGeneration) {
|
|
1165
|
+
int64_t requestId = 0;
|
|
1166
|
+
uint64_t generation = 0;
|
|
1167
|
+
{
|
|
1168
|
+
std::lock_guard lock(mutex_);
|
|
1169
|
+
generation = processGeneration_;
|
|
1170
|
+
if (generation == 0 || generation != expectedGeneration || stdinFd_ < 0) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
requestId = nextRequestId_++;
|
|
1174
|
+
ignoredResponseIds_.insert(requestId);
|
|
1175
|
+
}
|
|
1176
|
+
@autoreleasepool {
|
|
1177
|
+
try {
|
|
1178
|
+
sendJson(@{
|
|
1179
|
+
@"id": @(requestId),
|
|
1180
|
+
@"method": @"turn/interrupt",
|
|
1181
|
+
@"params": @{
|
|
1182
|
+
@"threadId": toNSString(threadId),
|
|
1183
|
+
@"turnId": toNSString(turnId),
|
|
1184
|
+
},
|
|
1185
|
+
}, generation, UINT64_MAX, Clock::now() + std::chrono::milliseconds(100));
|
|
1186
|
+
} catch (...) {
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
void sendJson(NSDictionary* value, uint64_t generation, uint64_t expectedCancellationGeneration = UINT64_MAX, Clock::time_point deadline = Clock::time_point::max()) {
|
|
1192
|
+
std::string json = serializeJson(value);
|
|
1193
|
+
json.push_back('\n');
|
|
1194
|
+
uint64_t cancellationGeneration = 0;
|
|
1195
|
+
{ std::lock_guard lock(mutex_); cancellationGeneration = expectedCancellationGeneration == UINT64_MAX ? cancelGeneration_ : expectedCancellationGeneration; }
|
|
1196
|
+
std::unique_lock writeLock(writeMutex_, std::defer_lock);
|
|
1197
|
+
const auto writeDeadline = std::min(deadline, Clock::now() + std::chrono::seconds(1));
|
|
1198
|
+
while (!writeLock.try_lock_for(std::chrono::milliseconds(10))) {
|
|
1199
|
+
{ std::lock_guard lock(mutex_); if (generation != processGeneration_ || (cancellationGeneration != UINT64_MAX && cancelGeneration_ != cancellationGeneration)) throw std::runtime_error("Codex request was cancelled."); }
|
|
1200
|
+
if (Clock::now() >= writeDeadline) throw std::runtime_error("Timed out waiting to write to Codex app-server.");
|
|
1201
|
+
}
|
|
1202
|
+
int fd = -1;
|
|
1203
|
+
{
|
|
1204
|
+
std::lock_guard lock(mutex_);
|
|
1205
|
+
if (generation == 0 || generation != processGeneration_ || stdinFd_ < 0) {
|
|
1206
|
+
throw std::runtime_error(processError_.empty() ? "Codex app-server is not running." : processError_);
|
|
1207
|
+
}
|
|
1208
|
+
fd = fcntl(stdinFd_, F_DUPFD_CLOEXEC, 0);
|
|
1209
|
+
if (fd < 0) throw std::runtime_error("Could not duplicate Codex app-server input: " + std::string(strerror(errno)));
|
|
1210
|
+
}
|
|
1211
|
+
size_t offset = 0;
|
|
1212
|
+
bool reportedBlocked = false;
|
|
1213
|
+
try {
|
|
1214
|
+
while (offset < json.size()) {
|
|
1215
|
+
{
|
|
1216
|
+
std::lock_guard lock(mutex_);
|
|
1217
|
+
if (generation != processGeneration_ || (cancellationGeneration != UINT64_MAX && cancelGeneration_ != cancellationGeneration)) {
|
|
1218
|
+
throw std::runtime_error("Codex request was cancelled.");
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (Clock::now() >= writeDeadline) throw std::runtime_error("Timed out writing to Codex app-server.");
|
|
1222
|
+
const ssize_t written = write(fd, json.data() + offset, json.size() - offset);
|
|
1223
|
+
if (written > 0) {
|
|
1224
|
+
offset += static_cast<size_t>(written);
|
|
1225
|
+
} else if (written < 0 && errno == EINTR) {
|
|
1226
|
+
continue;
|
|
1227
|
+
} else if (written < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
|
|
1228
|
+
if (!reportedBlocked) {
|
|
1229
|
+
std::lock_guard lock(mutex_);
|
|
1230
|
+
++blockedWriteCount_;
|
|
1231
|
+
reportedBlocked = true;
|
|
1232
|
+
}
|
|
1233
|
+
pollfd descriptor{fd, POLLOUT, 0};
|
|
1234
|
+
poll(&descriptor, 1, 25);
|
|
1235
|
+
} else {
|
|
1236
|
+
throw std::runtime_error("Could not write to Codex app-server: " + std::string(strerror(errno)));
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
} catch (...) {
|
|
1240
|
+
close(fd);
|
|
1241
|
+
if (reportedBlocked) { std::lock_guard lock(mutex_); --blockedWriteCount_; }
|
|
1242
|
+
if (offset > 0) terminateProcessGeneration(generation, "Codex app-server request write did not complete.");
|
|
1243
|
+
throw;
|
|
1244
|
+
}
|
|
1245
|
+
if (reportedBlocked) { std::lock_guard lock(mutex_); --blockedWriteCount_; }
|
|
1246
|
+
close(fd);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
void readStdout(int fd, uint64_t generation) {
|
|
1250
|
+
std::string pending;
|
|
1251
|
+
char buffer[8192];
|
|
1252
|
+
while (true) {
|
|
1253
|
+
const ssize_t count = read(fd, buffer, sizeof(buffer));
|
|
1254
|
+
if (count > 0) {
|
|
1255
|
+
pending.append(buffer, static_cast<size_t>(count));
|
|
1256
|
+
if (pending.size() > kMaximumMessageBytes) {
|
|
1257
|
+
markProtocolFailure(generation, "Codex app-server sent a message that was too large.");
|
|
1258
|
+
break;
|
|
1259
|
+
}
|
|
1260
|
+
size_t newline = std::string::npos;
|
|
1261
|
+
while ((newline = pending.find('\n')) != std::string::npos) {
|
|
1262
|
+
std::string line = pending.substr(0, newline);
|
|
1263
|
+
pending.erase(0, newline + 1);
|
|
1264
|
+
if (!line.empty()) {
|
|
1265
|
+
handleMessage(line, generation);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
} else if (count < 0 && errno == EINTR) {
|
|
1269
|
+
continue;
|
|
1270
|
+
} else {
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
close(fd);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
void readStderr(int fd, uint64_t generation) {
|
|
1278
|
+
char buffer[4096];
|
|
1279
|
+
while (true) {
|
|
1280
|
+
const ssize_t count = read(fd, buffer, sizeof(buffer));
|
|
1281
|
+
if (count > 0) {
|
|
1282
|
+
std::lock_guard lock(mutex_);
|
|
1283
|
+
if (processGeneration_ == generation) {
|
|
1284
|
+
stderrTail_.append(buffer, static_cast<size_t>(count));
|
|
1285
|
+
if (stderrTail_.size() > kMaximumStderrBytes) {
|
|
1286
|
+
stderrTail_.erase(0, stderrTail_.size() - kMaximumStderrBytes);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
} else if (count < 0 && errno == EINTR) {
|
|
1290
|
+
continue;
|
|
1291
|
+
} else {
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
close(fd);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
void handleMessage(const std::string& line, uint64_t generation) {
|
|
1299
|
+
@autoreleasepool {
|
|
1300
|
+
NSDictionary* message = nil;
|
|
1301
|
+
try {
|
|
1302
|
+
message = parseJsonObject(line, "Codex app-server returned invalid JSON");
|
|
1303
|
+
} catch (const std::exception& error) {
|
|
1304
|
+
markProtocolFailure(generation, error.what());
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
id rawRequestId = message[@"id"];
|
|
1309
|
+
NSNumber* numericRequestId = [rawRequestId isKindOfClass:[NSNumber class]] ? rawRequestId : nil;
|
|
1310
|
+
const bool hasRequestId = numericRequestId != nil || [rawRequestId isKindOfClass:[NSString class]];
|
|
1311
|
+
NSString* method = stringValue(message[@"method"]);
|
|
1312
|
+
if (numericRequestId != nil && method == nil) {
|
|
1313
|
+
std::lock_guard lock(mutex_);
|
|
1314
|
+
if (processGeneration_ != generation) {
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
const int64_t identifier = numericRequestId.longLongValue;
|
|
1318
|
+
if (ignoredResponseIds_.erase(identifier) == 0) {
|
|
1319
|
+
responses_[identifier] = line;
|
|
1320
|
+
}
|
|
1321
|
+
condition_.notify_all();
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
if (method == nil) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
if (hasRequestId) {
|
|
1328
|
+
rejectServerRequest(rawRequestId, generation);
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
NSDictionary* params = dictionaryValue(message[@"params"]);
|
|
1333
|
+
if ([method isEqualToString:@"item/completed"]) {
|
|
1334
|
+
NSDictionary* item = dictionaryValue(params[@"item"]);
|
|
1335
|
+
if ([stringValue(item[@"type"]) isEqualToString:@"agentMessage"]) {
|
|
1336
|
+
const std::string turnId = toString(stringValue(params[@"turnId"]));
|
|
1337
|
+
const std::string text = toString(stringValue(item[@"text"]));
|
|
1338
|
+
std::lock_guard lock(mutex_);
|
|
1339
|
+
if (processGeneration_ == generation && !turnId.empty()) {
|
|
1340
|
+
if (TurnState* state = pendingOrActiveTurnLocked(generation, turnId)) setPreAckTextLocked(*state, &TurnState::output, text);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
} else if ([method isEqualToString:@"error"]) {
|
|
1344
|
+
const std::string turnId = toString(stringValue(params[@"turnId"]));
|
|
1345
|
+
NSDictionary* error = dictionaryValue(params[@"error"]);
|
|
1346
|
+
const std::string errorMessage = toString(stringValue(error[@"message"]));
|
|
1347
|
+
const bool willRetry = boolValue(params[@"willRetry"]);
|
|
1348
|
+
std::lock_guard lock(mutex_);
|
|
1349
|
+
if (processGeneration_ == generation && !turnId.empty() && !willRetry) {
|
|
1350
|
+
if (TurnState* state = pendingOrActiveTurnLocked(generation, turnId)) setPreAckTextLocked(*state, &TurnState::error, errorMessage);
|
|
1351
|
+
}
|
|
1352
|
+
} else if ([method isEqualToString:@"turn/completed"]) {
|
|
1353
|
+
NSDictionary* turn = dictionaryValue(params[@"turn"]);
|
|
1354
|
+
const std::string turnId = toString(stringValue(turn[@"id"]));
|
|
1355
|
+
const std::string status = toString(stringValue(turn[@"status"]));
|
|
1356
|
+
std::string output;
|
|
1357
|
+
for (id rawItem in arrayValue(turn[@"items"]) ?: @[]) {
|
|
1358
|
+
NSDictionary* item = dictionaryValue(rawItem);
|
|
1359
|
+
if ([stringValue(item[@"type"]) isEqualToString:@"agentMessage"]) {
|
|
1360
|
+
output = toString(stringValue(item[@"text"]));
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
NSDictionary* error = dictionaryValue(turn[@"error"]);
|
|
1364
|
+
std::string errorMessage = toString(stringValue(error[@"message"]));
|
|
1365
|
+
if (errorMessage.empty() && status != "completed") {
|
|
1366
|
+
errorMessage = status.empty() ? "Codex turn failed." : "Codex turn " + status + ".";
|
|
1367
|
+
}
|
|
1368
|
+
std::lock_guard lock(mutex_);
|
|
1369
|
+
if (processGeneration_ == generation && !turnId.empty()) {
|
|
1370
|
+
TurnState* existing = pendingOrActiveTurnLocked(generation, turnId); if (existing == nullptr) return;
|
|
1371
|
+
TurnState& state = *existing;
|
|
1372
|
+
if (!output.empty()) {
|
|
1373
|
+
setPreAckTextLocked(state, &TurnState::output, output);
|
|
1374
|
+
}
|
|
1375
|
+
setPreAckTextLocked(state, &TurnState::error, errorMessage);
|
|
1376
|
+
state.done = true;
|
|
1377
|
+
condition_.notify_all();
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
void rejectServerRequest(id requestId, uint64_t generation) {
|
|
1384
|
+
@autoreleasepool {
|
|
1385
|
+
try {
|
|
1386
|
+
sendJson(@{
|
|
1387
|
+
@"error": @{
|
|
1388
|
+
@"code": @(-32601),
|
|
1389
|
+
@"message": @"Legend Apps does not support this Codex server request.",
|
|
1390
|
+
},
|
|
1391
|
+
@"id": requestId,
|
|
1392
|
+
}, generation);
|
|
1393
|
+
} catch (...) {
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
void markProtocolFailure(uint64_t generation, const std::string& message) {
|
|
1399
|
+
std::lock_guard lock(mutex_);
|
|
1400
|
+
if (processGeneration_ != generation) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
processError_ = actionableError(message);
|
|
1404
|
+
for (auto& [key, state] : turns_) {
|
|
1405
|
+
if (key.first != generation) continue;
|
|
1406
|
+
state.error = processError_;
|
|
1407
|
+
state.done = true;
|
|
1408
|
+
}
|
|
1409
|
+
condition_.notify_all();
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
void processExited(pid_t pid, uint64_t generation, int status) {
|
|
1413
|
+
std::lock_guard lock(mutex_);
|
|
1414
|
+
if (processGeneration_ != generation || pid_ != pid) {
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (stdinFd_ >= 0) {
|
|
1418
|
+
close(stdinFd_);
|
|
1419
|
+
}
|
|
1420
|
+
stdinFd_ = -1;
|
|
1421
|
+
pid_ = -1;
|
|
1422
|
+
initialized_ = false;
|
|
1423
|
+
std::string detail;
|
|
1424
|
+
if (WIFEXITED(status)) {
|
|
1425
|
+
detail = "Codex app-server exited with status " + std::to_string(WEXITSTATUS(status)) + ".";
|
|
1426
|
+
} else if (WIFSIGNALED(status)) {
|
|
1427
|
+
detail = "Codex app-server stopped with signal " + std::to_string(WTERMSIG(status)) + ".";
|
|
1428
|
+
} else {
|
|
1429
|
+
detail = "Codex app-server exited unexpectedly.";
|
|
1430
|
+
}
|
|
1431
|
+
if (!stderrTail_.empty()) {
|
|
1432
|
+
detail += " " + stderrTail_;
|
|
1433
|
+
}
|
|
1434
|
+
processError_ = actionableError(detail);
|
|
1435
|
+
endGenerationLocked(generation, detail);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
static void throwForResponseError(NSDictionary* response, const std::string& context) {
|
|
1439
|
+
const std::string error = responseError(response);
|
|
1440
|
+
if (!error.empty()) {
|
|
1441
|
+
throw std::runtime_error(actionableError(context + ": " + error));
|
|
1442
|
+
}
|
|
1443
|
+
if (dictionaryValue(response[@"result"]) == nil) {
|
|
1444
|
+
throw std::runtime_error(
|
|
1445
|
+
context + ": Codex returned an invalid response. Update Codex, then reopen the app.");
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
std::condition_variable condition_;
|
|
1450
|
+
std::map<int64_t, std::string> responses_;
|
|
1451
|
+
std::set<int64_t> ignoredResponseIds_;
|
|
1452
|
+
std::set<pid_t> fallbackPids_;
|
|
1453
|
+
std::map<TurnKey, TurnState> turns_;
|
|
1454
|
+
std::set<std::string> retiredTurnIds_;
|
|
1455
|
+
std::deque<std::string> retiredTurnOrder_;
|
|
1456
|
+
std::timed_mutex lifecycleMutex_;
|
|
1457
|
+
std::mutex mutex_;
|
|
1458
|
+
std::timed_mutex writeMutex_;
|
|
1459
|
+
size_t activeRuns_ = 0;
|
|
1460
|
+
size_t blockedWriteCount_ = 0;
|
|
1461
|
+
size_t preAckBytes_ = 0;
|
|
1462
|
+
size_t pendingTurnStarts_ = 0;
|
|
1463
|
+
std::string codexPath_;
|
|
1464
|
+
std::string processError_;
|
|
1465
|
+
std::string stderrTail_;
|
|
1466
|
+
std::string userAgent_;
|
|
1467
|
+
int stdinFd_ = -1;
|
|
1468
|
+
int64_t nextRequestId_ = 1;
|
|
1469
|
+
pid_t pid_ = -1;
|
|
1470
|
+
uint64_t cancelGeneration_ = 0;
|
|
1471
|
+
uint64_t nextProcessGeneration_ = 0;
|
|
1472
|
+
uint64_t nextTurnSequence_ = 0;
|
|
1473
|
+
uint64_t processGeneration_ = 0;
|
|
1474
|
+
bool initialized_ = false;
|
|
1475
|
+
bool useExecFallback_ = false;
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
} // namespace
|
|
1479
|
+
|
|
1480
|
+
#if defined(SPARK_CODEX_TESTING)
|
|
1481
|
+
extern "C" int SparkCodexTestRunPrompt(const char* prompt, double timeoutMs, char* output, size_t outputCapacity, char* error, size_t errorCapacity) {
|
|
1482
|
+
auto copy = [](char* target, size_t capacity, const std::string& value) {
|
|
1483
|
+
if (capacity == 0) return;
|
|
1484
|
+
const size_t length = std::min(capacity - 1, value.size());
|
|
1485
|
+
std::memcpy(target, value.data(), length); target[length] = '\0';
|
|
1486
|
+
};
|
|
1487
|
+
try {
|
|
1488
|
+
const auto result = CodexProcessSupervisor::shared().runPrompt(prompt ?: "", "", "low", timeoutMs, "", "");
|
|
1489
|
+
copy(output, outputCapacity, result.output);
|
|
1490
|
+
return 0;
|
|
1491
|
+
} catch (const std::exception& exception) { copy(error, errorCapacity, exception.what()); return 1; }
|
|
1492
|
+
catch (...) { copy(error, errorCapacity, "unknown native failure"); return 1; }
|
|
1493
|
+
}
|
|
1494
|
+
extern "C" double SparkCodexTestCancel() { return CodexProcessSupervisor::shared().cancelActiveRuns(); }
|
|
1495
|
+
extern "C" double SparkCodexTestShutdown() { return CodexProcessSupervisor::shared().shutdown(); }
|
|
1496
|
+
extern "C" size_t SparkCodexTestRetainedTurns() { return CodexProcessSupervisor::shared().retainedTurnCountForTesting(); }
|
|
1497
|
+
extern "C" size_t SparkCodexTestBlockedWrites() { return CodexProcessSupervisor::shared().blockedWriteCountForTesting(); }
|
|
1498
|
+
#else
|
|
1499
|
+
|
|
1500
|
+
HybridCodexAppServer::HybridCodexAppServer() : HybridObject(TAG) {}
|
|
1501
|
+
|
|
1502
|
+
std::shared_ptr<Promise<CodexAvailability>> HybridCodexAppServer::getAvailability() {
|
|
1503
|
+
return Promise<CodexAvailability>::async([]() {
|
|
1504
|
+
return CodexProcessSupervisor::shared().getAvailability();
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
std::shared_ptr<Promise<CodexRunResult>> HybridCodexAppServer::runPrompt(
|
|
1509
|
+
const std::string& prompt,
|
|
1510
|
+
const std::string& cwd,
|
|
1511
|
+
const std::string& reasoningEffort,
|
|
1512
|
+
double timeoutMs,
|
|
1513
|
+
const std::string& outputSchemaJson,
|
|
1514
|
+
const std::string& developerInstructions) {
|
|
1515
|
+
return Promise<CodexRunResult>::async([
|
|
1516
|
+
prompt,
|
|
1517
|
+
cwd,
|
|
1518
|
+
reasoningEffort,
|
|
1519
|
+
timeoutMs,
|
|
1520
|
+
outputSchemaJson,
|
|
1521
|
+
developerInstructions]() {
|
|
1522
|
+
return CodexProcessSupervisor::shared().runPrompt(
|
|
1523
|
+
prompt,
|
|
1524
|
+
cwd,
|
|
1525
|
+
reasoningEffort,
|
|
1526
|
+
timeoutMs,
|
|
1527
|
+
outputSchemaJson,
|
|
1528
|
+
developerInstructions);
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
double HybridCodexAppServer::cancelActiveRuns() {
|
|
1533
|
+
return CodexProcessSupervisor::shared().cancelActiveRuns();
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
double HybridCodexAppServer::shutdown() {
|
|
1537
|
+
return CodexProcessSupervisor::shared().shutdown();
|
|
1538
|
+
}
|
|
1539
|
+
#endif
|
|
1540
|
+
|
|
1541
|
+
} // namespace margelo::nitro::legendapps::codex
|