@cryptiklemur/lattice 4.0.2 → 5.0.0
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/bin/lattice +1 -9
- package/dist/client/assets/{angular-html-N8PCEquT.js → angular-html-DKTL-XDO.js} +1 -1
- package/dist/client/assets/{angular-ts-CJ8RJIPD.js → angular-ts-tvBzOwQR.js} +1 -1
- package/dist/client/assets/{apl-BD6tCLWN.js → apl-CCzl5qFl.js} +1 -1
- package/dist/client/assets/{astro-CpIIfBs6.js → astro-DNQTpO2Y.js} +1 -1
- package/dist/client/assets/{blade-D3qgnjiV.js → blade-CyJoIMeJ.js} +1 -1
- package/dist/client/assets/{c-Dr6ADN_t.js → c-OEwk5KN8.js} +1 -1
- package/dist/client/assets/{cobol-BIfDE0Hr.js → cobol-DpHyJzz2.js} +1 -1
- package/dist/client/assets/{coffee-DHQ57vfY.js → coffee-BX5dbDzZ.js} +1 -1
- package/dist/client/assets/{cpp-CEBY6JOp.js → cpp-BTBjNg2U.js} +1 -1
- package/dist/client/assets/{crystal-D125CSmP.js → crystal-CNzZd6DW.js} +1 -1
- package/dist/client/assets/{css-CBmrkYSr.js → css-BuKsNmms.js} +1 -1
- package/dist/client/assets/{dist-A_mCRD1f.js → dist-CKpDHMy6.js} +2 -2
- package/dist/client/assets/{edge-Ccsz7cJW.js → edge-DzhnGgJE.js} +1 -1
- package/dist/client/assets/{elixir-Do6gk14X.js → elixir-Dqs0waqF.js} +1 -1
- package/dist/client/assets/{elm-Db22zT4C.js → elm-BtWwjxWn.js} +1 -1
- package/dist/client/assets/{erb-MXVqAAJD.js → erb-iPD89b4v.js} +1 -1
- package/dist/client/assets/{git-rebase-B-LLWBOA.js → git-rebase-BxVNXJL4.js} +1 -1
- package/dist/client/assets/{glimmer-js-eWszRU73.js → glimmer-js-BlyCupwF.js} +1 -1
- package/dist/client/assets/{glimmer-ts-VQmwGqUp.js → glimmer-ts-DjIxWOS9.js} +1 -1
- package/dist/client/assets/{glsl-B8ilOfAl.js → glsl-CGIL-65r.js} +1 -1
- package/dist/client/assets/{graphql-DnTqxeOc.js → graphql-DeOn6mNV.js} +1 -1
- package/dist/client/assets/{hack-XJsHYSQb.js → hack-DVppeCmS.js} +1 -1
- package/dist/client/assets/{haml-CQ7Vqzwp.js → haml-WDhua0Mp.js} +1 -1
- package/dist/client/assets/{handlebars-C4szooBf.js → handlebars-i2Fu_9HI.js} +1 -1
- package/dist/client/assets/{html-B6EgAiSd.js → html-B1e6oxzK.js} +1 -1
- package/dist/client/assets/{html-derivative-DdinogQX.js → html-derivative-MofKXIVd.js} +1 -1
- package/dist/client/assets/{http-BSLxCgRq.js → http-Dk6S5pRD.js} +1 -1
- package/dist/client/assets/{hurl-pOsTwNfp.js → hurl-CroFYYJG.js} +1 -1
- package/dist/client/assets/{index-BHQ_8mvl.js → index-CVu-S6Yk.js} +2 -2
- package/dist/client/assets/{java-DRQLiiST.js → java-B89FYjqS.js} +1 -1
- package/dist/client/assets/{javascript-DvEK2-47.js → javascript-m6CO1Uiy.js} +1 -1
- package/dist/client/assets/{jinja-D2NYJ25y.js → jinja-DC9Wi41X.js} +1 -1
- package/dist/client/assets/{jison-DDZaLNAp.js → jison-6xiegwDk.js} +1 -1
- package/dist/client/assets/{json-TGR0NIWd.js → json-HA-96-qr.js} +1 -1
- package/dist/client/assets/{jsx-BjUoPYga.js → jsx-Wt1a8i8U.js} +1 -1
- package/dist/client/assets/{julia-C4gjSpFu.js → julia-7M93VBON.js} +1 -1
- package/dist/client/assets/{just-H351x5u_.js → just-CjfDLYLv.js} +1 -1
- package/dist/client/assets/{latex-BiTmf6gf.js → latex-CitsJ46x.js} +1 -1
- package/dist/client/assets/{liquid-86ufjRy-.js → liquid-C8VIFin8.js} +1 -1
- package/dist/client/assets/{lua-BNxR0F_8.js → lua-Ba2N7esc.js} +1 -1
- package/dist/client/assets/{marko-CvRxpRjM.js → marko-lTLvb2wu.js} +1 -1
- package/dist/client/assets/{mdc-CYbAIy2C.js → mdc-D6IV-8FD.js} +1 -1
- package/dist/client/assets/{nginx-egdgMq-F.js → nginx-Ch5AjE6S.js} +1 -1
- package/dist/client/assets/{nim-CXBJVz_w.js → nim-WmDDC6LW.js} +1 -1
- package/dist/client/assets/{perl-XRfMobzg.js → perl-CQv0gYuq.js} +1 -1
- package/dist/client/assets/{php-Br7a8uil.js → php-BJmH0qOB.js} +1 -1
- package/dist/client/assets/{pug-BVbbUVvy.js → pug-CsHPkzc9.js} +1 -1
- package/dist/client/assets/{qml-ByKvrL1j.js → qml-B36ecArG.js} +1 -1
- package/dist/client/assets/{r-mVoV0Ni6.js → r-D5Yi5Z4y.js} +1 -1
- package/dist/client/assets/{razor-T5O-9UJL.js → razor-CHAxVq4R.js} +1 -1
- package/dist/client/assets/{regexp-CioRuhuN.js → regexp-gfs--3M7.js} +1 -1
- package/dist/client/assets/{rst-V__uTudD.js → rst-ugdlp-hl.js} +1 -1
- package/dist/client/assets/{ruby-C_PuKPTI.js → ruby-CDRRW37j.js} +1 -1
- package/dist/client/assets/{sas-D_DqqQH4.js → sas-DZaNQaIP.js} +1 -1
- package/dist/client/assets/{scss-D-TjzZ4c.js → scss-CzWQEplj.js} +1 -1
- package/dist/client/assets/{shellscript-E5759VHu.js → shellscript-fgYvpu9N.js} +1 -1
- package/dist/client/assets/{shellsession-AESTM-Pv.js → shellsession-BoAohHh7.js} +1 -1
- package/dist/client/assets/{soy-QrbrrcDv.js → soy-DBzVgv9x.js} +1 -1
- package/dist/client/assets/{sql-0M8VcDHD.js → sql-BYXpAYTs.js} +1 -1
- package/dist/client/assets/{stata-CgeIpGtc.js → stata-I71MMY3p.js} +1 -1
- package/dist/client/assets/{surrealql-DBGwnZbw.js → surrealql-C9U8_1VO.js} +1 -1
- package/dist/client/assets/{svelte-Cv0PvUc_.js → svelte-VOFrPnWT.js} +1 -1
- package/dist/client/assets/{templ-B9t7xRE4.js → templ-BIaxAEtC.js} +1 -1
- package/dist/client/assets/{tex-DhZZ8dr2.js → tex-D1dwnBE5.js} +1 -1
- package/dist/client/assets/{ts-tags-BFv8sbnd.js → ts-tags-C0L2Q0r5.js} +1 -1
- package/dist/client/assets/{tsx-CXC9KSbY.js → tsx-BqcycEv1.js} +1 -1
- package/dist/client/assets/{twig-CM_OO66r.js → twig-vyWqOhpM.js} +1 -1
- package/dist/client/assets/{typescript-BdgOTaoD.js → typescript-B2YbovqG.js} +1 -1
- package/dist/client/assets/{vue-BnQhjnCm.js → vue-CbXxGdjo.js} +1 -1
- package/dist/client/assets/{vue-html-CNnGecRI.js → vue-html-DDX4KXW7.js} +1 -1
- package/dist/client/assets/{vue-vine-DCuMkRhK.js → vue-vine-DsyY1LR5.js} +1 -1
- package/dist/client/assets/{xml-CbTD7cB8.js → xml-Ddi0-r0D.js} +1 -1
- package/dist/client/assets/{xsl-uOqqo7cf.js → xsl-CsFcZHFS.js} +1 -1
- package/dist/client/assets/{yaml-BNrLoH59.js → yaml-tGJWoH6Y.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/sw.js +1 -1
- package/dist/server/analytics/engine.js +832 -0
- package/dist/server/assets.js +39 -0
- package/dist/server/auth/passphrase.js +70 -0
- package/dist/server/config.js +47 -0
- package/dist/server/daemon.js +535 -0
- package/dist/server/features/ralph-loop.js +138 -0
- package/dist/server/features/scheduler.js +260 -0
- package/dist/server/features/sticky-notes.js +99 -0
- package/dist/server/handlers/analytics.js +28 -0
- package/dist/server/handlers/attachment.js +158 -0
- package/dist/server/handlers/bookmarks.js +41 -0
- package/dist/server/handlers/chat.js +350 -0
- package/dist/server/handlers/editor.js +72 -0
- package/dist/server/handlers/fs.js +234 -0
- package/dist/server/handlers/loop.js +33 -0
- package/dist/server/handlers/memory.js +181 -0
- package/dist/server/handlers/mesh.js +322 -0
- package/dist/server/handlers/notes.js +36 -0
- package/dist/server/handlers/plugins.js +593 -0
- package/dist/server/handlers/project-settings.js +166 -0
- package/dist/server/handlers/scheduler.js +52 -0
- package/dist/server/handlers/session.js +194 -0
- package/dist/server/handlers/settings.js +148 -0
- package/dist/server/handlers/skills.js +360 -0
- package/dist/server/handlers/terminal.js +75 -0
- package/dist/server/handlers/themes.js +102 -0
- package/dist/server/handlers/update.js +124 -0
- package/dist/server/identity.js +45 -0
- package/dist/server/index.js +435 -0
- package/dist/server/logger.js +20 -0
- package/dist/server/mesh/connector.js +355 -0
- package/dist/server/mesh/crypto.js +88 -0
- package/dist/server/mesh/discovery.js +95 -0
- package/dist/server/mesh/pairing.js +104 -0
- package/dist/server/mesh/peers.js +54 -0
- package/dist/server/mesh/proxy.js +86 -0
- package/dist/server/mesh/session-sync.js +85 -0
- package/dist/server/project/bookmarks.js +77 -0
- package/dist/server/project/context-breakdown.js +279 -0
- package/dist/server/project/file-browser.js +97 -0
- package/dist/server/project/project-files.js +274 -0
- package/dist/server/project/registry.js +51 -0
- package/dist/server/project/sdk-bridge.js +960 -0
- package/dist/server/project/session.js +696 -0
- package/dist/server/project/terminal.js +87 -0
- package/dist/server/project/warmup.js +242 -0
- package/dist/server/push.js +87 -0
- package/dist/server/tls.js +50 -0
- package/dist/server/tui.js +83 -0
- package/dist/server/update-checker.js +119 -0
- package/dist/server/ws/broadcast.js +50 -0
- package/dist/server/ws/router.js +105 -0
- package/dist/server/ws/server.js +2 -0
- package/dist/shared/analytics.js +1 -0
- package/dist/shared/messages.js +1 -0
- package/dist/shared/models.js +1 -0
- package/dist/shared/project-settings.js +1 -0
- package/package.json +5 -8
- package/themes/alabaster.json +9 -0
- package/themes/amoled.json +20 -0
- package/themes/ayu-light.json +9 -0
- package/themes/catppuccin-latte.json +9 -0
- package/themes/catppuccin-mocha.json +9 -0
- package/themes/clay-light.json +10 -0
- package/themes/clay.json +10 -0
- package/themes/dracula.json +9 -0
- package/themes/everforest-light.json +9 -0
- package/themes/everforest.json +9 -0
- package/themes/github-light.json +9 -0
- package/themes/gruvbox-dark.json +9 -0
- package/themes/gruvbox-light.json +9 -0
- package/themes/horizon-light.json +9 -0
- package/themes/kanagawa-lotus.json +9 -0
- package/themes/kanagawa.json +9 -0
- package/themes/modus-operandi.json +9 -0
- package/themes/monokai.json +9 -0
- package/themes/nightfox.json +9 -0
- package/themes/nord-light.json +9 -0
- package/themes/nord.json +9 -0
- package/themes/one-dark.json +9 -0
- package/themes/one-light.json +9 -0
- package/themes/palenight.json +9 -0
- package/themes/paper.json +9 -0
- package/themes/penumbra-light.json +9 -0
- package/themes/poimandres.json +9 -0
- package/themes/quiet-light.json +9 -0
- package/themes/rose-pine-dawn.json +9 -0
- package/themes/rose-pine.json +9 -0
- package/themes/solarized-dark.json +9 -0
- package/themes/solarized-light.json +9 -0
- package/themes/synthwave84.json +9 -0
- package/themes/tokyo-night-light.json +9 -0
- package/themes/tokyo-night.json +9 -0
- package/themes/vesper.json +9 -0
- package/index.html +0 -20
- package/public/icons/icon-192.svg +0 -11
- package/public/icons/icon-512.svg +0 -11
- package/public/sw-push.js +0 -53
- package/src/client/App.tsx +0 -42
- package/src/client/commands.ts +0 -36
- package/src/client/components/analytics/AnalyticsView.tsx +0 -244
- package/src/client/components/analytics/ChartCard.tsx +0 -194
- package/src/client/components/analytics/PeriodSelector.tsx +0 -42
- package/src/client/components/analytics/QuickStats.tsx +0 -122
- package/src/client/components/analytics/chartTokens.ts +0 -188
- package/src/client/components/analytics/charts/ActivityCalendar.tsx +0 -204
- package/src/client/components/analytics/charts/CacheEfficiencyChart.tsx +0 -56
- package/src/client/components/analytics/charts/ContextUtilizationChart.tsx +0 -106
- package/src/client/components/analytics/charts/CostAreaChart.tsx +0 -79
- package/src/client/components/analytics/charts/CostDistributionChart.tsx +0 -59
- package/src/client/components/analytics/charts/CostDonutChart.tsx +0 -84
- package/src/client/components/analytics/charts/CumulativeCostChart.tsx +0 -59
- package/src/client/components/analytics/charts/DailySummaryCards.tsx +0 -86
- package/src/client/components/analytics/charts/HourlyHeatmap.tsx +0 -133
- package/src/client/components/analytics/charts/NodeFleetOverview.tsx +0 -89
- package/src/client/components/analytics/charts/PermissionBreakdown.tsx +0 -98
- package/src/client/components/analytics/charts/ProjectRadar.tsx +0 -126
- package/src/client/components/analytics/charts/ResponseTimeScatter.tsx +0 -96
- package/src/client/components/analytics/charts/SessionBubbleChart.tsx +0 -114
- package/src/client/components/analytics/charts/SessionComplexityList.tsx +0 -65
- package/src/client/components/analytics/charts/SessionTimeline.tsx +0 -107
- package/src/client/components/analytics/charts/TokenFlowChart.tsx +0 -78
- package/src/client/components/analytics/charts/TokenSankeyChart.tsx +0 -93
- package/src/client/components/analytics/charts/ToolSunburst.tsx +0 -123
- package/src/client/components/analytics/charts/ToolTreemap.tsx +0 -110
- package/src/client/components/auth/PassphrasePrompt.tsx +0 -70
- package/src/client/components/chat/AttachmentChips.tsx +0 -116
- package/src/client/components/chat/ChatInput.tsx +0 -533
- package/src/client/components/chat/ChatView.tsx +0 -1076
- package/src/client/components/chat/CommandPalette.tsx +0 -162
- package/src/client/components/chat/ElicitationCard.tsx +0 -238
- package/src/client/components/chat/Message.tsx +0 -825
- package/src/client/components/chat/ModelSelector.tsx +0 -108
- package/src/client/components/chat/PermissionModeSelector.tsx +0 -41
- package/src/client/components/chat/PromptQuestion.tsx +0 -271
- package/src/client/components/chat/StatusBar.tsx +0 -50
- package/src/client/components/chat/TodoCard.tsx +0 -57
- package/src/client/components/chat/ToolGroup.tsx +0 -129
- package/src/client/components/chat/ToolResultRenderer.tsx +0 -348
- package/src/client/components/chat/VoiceRecorder.tsx +0 -85
- package/src/client/components/chat/toolSummary.ts +0 -41
- package/src/client/components/dashboard/DashboardView.tsx +0 -200
- package/src/client/components/dashboard/ProjectDashboardView.tsx +0 -179
- package/src/client/components/mesh/NodeBadge.tsx +0 -24
- package/src/client/components/mesh/PairingDialog.tsx +0 -340
- package/src/client/components/project-settings/ProjectClaude.tsx +0 -318
- package/src/client/components/project-settings/ProjectEnvironment.tsx +0 -235
- package/src/client/components/project-settings/ProjectGeneral.tsx +0 -76
- package/src/client/components/project-settings/ProjectMcp.tsx +0 -232
- package/src/client/components/project-settings/ProjectMemory.tsx +0 -488
- package/src/client/components/project-settings/ProjectNotifications.tsx +0 -48
- package/src/client/components/project-settings/ProjectPermissions.tsx +0 -209
- package/src/client/components/project-settings/ProjectPlugins.tsx +0 -117
- package/src/client/components/project-settings/ProjectRules.tsx +0 -286
- package/src/client/components/project-settings/ProjectSettingsView.tsx +0 -117
- package/src/client/components/project-settings/ProjectSkills.tsx +0 -91
- package/src/client/components/settings/Appearance.tsx +0 -275
- package/src/client/components/settings/BudgetSettings.tsx +0 -165
- package/src/client/components/settings/ClaudeSettings.tsx +0 -175
- package/src/client/components/settings/Editor.tsx +0 -123
- package/src/client/components/settings/Environment.tsx +0 -185
- package/src/client/components/settings/GlobalMcp.tsx +0 -216
- package/src/client/components/settings/GlobalMemory.tsx +0 -19
- package/src/client/components/settings/GlobalPlugins.tsx +0 -806
- package/src/client/components/settings/GlobalRules.tsx +0 -149
- package/src/client/components/settings/GlobalSkills.tsx +0 -140
- package/src/client/components/settings/MeshStatus.tsx +0 -183
- package/src/client/components/settings/Notifications.tsx +0 -123
- package/src/client/components/settings/SettingsView.tsx +0 -75
- package/src/client/components/settings/SkillMarketplace.tsx +0 -175
- package/src/client/components/settings/ThemePreview.tsx +0 -140
- package/src/client/components/settings/ThemeWizard.tsx +0 -405
- package/src/client/components/settings/mcp-shared.tsx +0 -194
- package/src/client/components/settings/skill-shared.tsx +0 -186
- package/src/client/components/setup/SetupWizard.tsx +0 -755
- package/src/client/components/sidebar/AddProjectModal.tsx +0 -438
- package/src/client/components/sidebar/NodeSettingsModal.tsx +0 -206
- package/src/client/components/sidebar/ProjectDropdown.tsx +0 -211
- package/src/client/components/sidebar/ProjectRail.tsx +0 -353
- package/src/client/components/sidebar/SearchFilter.tsx +0 -52
- package/src/client/components/sidebar/SessionList.tsx +0 -599
- package/src/client/components/sidebar/SettingsSidebar.tsx +0 -139
- package/src/client/components/sidebar/Sidebar.tsx +0 -469
- package/src/client/components/sidebar/UserIsland.tsx +0 -282
- package/src/client/components/sidebar/UserMenu.tsx +0 -107
- package/src/client/components/ui/CommandPalette.tsx +0 -321
- package/src/client/components/ui/ContextMenu.tsx +0 -153
- package/src/client/components/ui/ErrorBoundary.tsx +0 -56
- package/src/client/components/ui/IconPicker.tsx +0 -184
- package/src/client/components/ui/KeyboardShortcuts.tsx +0 -129
- package/src/client/components/ui/LatticeLogomark.tsx +0 -19
- package/src/client/components/ui/NodeDisconnectedOverlay.tsx +0 -35
- package/src/client/components/ui/PopupMenu.tsx +0 -120
- package/src/client/components/ui/SaveFooter.tsx +0 -63
- package/src/client/components/ui/Toast.tsx +0 -132
- package/src/client/components/ui/UpdateBanner.tsx +0 -110
- package/src/client/components/ui/UpdatePrompt.tsx +0 -47
- package/src/client/components/workspace/BookmarksView.tsx +0 -156
- package/src/client/components/workspace/FileBrowser.tsx +0 -174
- package/src/client/components/workspace/FileTree.tsx +0 -129
- package/src/client/components/workspace/FileViewer.tsx +0 -211
- package/src/client/components/workspace/NoteCard.tsx +0 -120
- package/src/client/components/workspace/NotesView.tsx +0 -102
- package/src/client/components/workspace/ScheduledTasksView.tsx +0 -117
- package/src/client/components/workspace/SplitPane.tsx +0 -81
- package/src/client/components/workspace/TabBar.tsx +0 -170
- package/src/client/components/workspace/TaskCard.tsx +0 -159
- package/src/client/components/workspace/TaskEditModal.tsx +0 -129
- package/src/client/components/workspace/TerminalInstance.tsx +0 -171
- package/src/client/components/workspace/TerminalView.tsx +0 -110
- package/src/client/components/workspace/WorkspaceView.tsx +0 -141
- package/src/client/hooks/useAnalytics.ts +0 -84
- package/src/client/hooks/useAttachments.ts +0 -313
- package/src/client/hooks/useBookmarks.ts +0 -57
- package/src/client/hooks/useEditorConfig.ts +0 -28
- package/src/client/hooks/useFocusTrap.ts +0 -74
- package/src/client/hooks/useIdleDetection.ts +0 -50
- package/src/client/hooks/useInstallPrompt.ts +0 -53
- package/src/client/hooks/useMesh.ts +0 -89
- package/src/client/hooks/useNotifications.ts +0 -54
- package/src/client/hooks/useOnline.ts +0 -6
- package/src/client/hooks/useProjectSettings.ts +0 -56
- package/src/client/hooks/useProjects.ts +0 -98
- package/src/client/hooks/usePushNotifications.ts +0 -92
- package/src/client/hooks/useSaveState.ts +0 -65
- package/src/client/hooks/useSession.ts +0 -580
- package/src/client/hooks/useSidebar.ts +0 -90
- package/src/client/hooks/useSkills.ts +0 -30
- package/src/client/hooks/useSpinnerVerb.ts +0 -36
- package/src/client/hooks/useSwipeDrawer.ts +0 -299
- package/src/client/hooks/useTheme.ts +0 -114
- package/src/client/hooks/useTimeTick.ts +0 -35
- package/src/client/hooks/useVoiceRecorder.ts +0 -169
- package/src/client/hooks/useWebSocket.ts +0 -27
- package/src/client/hooks/useWorkspace.ts +0 -57
- package/src/client/lib/theme-derive.ts +0 -196
- package/src/client/lib/workspace-url.ts +0 -219
- package/src/client/main.tsx +0 -10
- package/src/client/providers/WebSocketProvider.tsx +0 -186
- package/src/client/router.tsx +0 -578
- package/src/client/stores/analytics.ts +0 -68
- package/src/client/stores/bookmarks.ts +0 -45
- package/src/client/stores/mesh.ts +0 -78
- package/src/client/stores/session.ts +0 -569
- package/src/client/stores/sidebar.ts +0 -530
- package/src/client/stores/theme.ts +0 -44
- package/src/client/stores/workspace.ts +0 -518
- package/src/client/styles/global.css +0 -391
- package/src/client/styles/theme-vars.css +0 -18
- package/src/client/themes/index.ts +0 -105
- package/src/client/utils/editorUrl.ts +0 -55
- package/src/client/utils/findDuplicateKeys.ts +0 -12
- package/src/client/utils/formatSessionTitle.ts +0 -17
- package/src/client/vite-env.d.ts +0 -6
- package/src/server/analytics/engine.ts +0 -920
- package/src/server/assets.ts +0 -45
- package/src/server/auth/passphrase.ts +0 -78
- package/src/server/config.ts +0 -55
- package/src/server/daemon.ts +0 -567
- package/src/server/features/ralph-loop.ts +0 -173
- package/src/server/features/scheduler.ts +0 -304
- package/src/server/features/sticky-notes.ts +0 -104
- package/src/server/handlers/analytics.ts +0 -39
- package/src/server/handlers/attachment.ts +0 -189
- package/src/server/handlers/bookmarks.ts +0 -50
- package/src/server/handlers/chat.ts +0 -381
- package/src/server/handlers/editor.ts +0 -76
- package/src/server/handlers/fs.ts +0 -251
- package/src/server/handlers/loop.ts +0 -37
- package/src/server/handlers/memory.ts +0 -182
- package/src/server/handlers/mesh.ts +0 -362
- package/src/server/handlers/notes.ts +0 -47
- package/src/server/handlers/plugins.ts +0 -655
- package/src/server/handlers/project-settings.ts +0 -180
- package/src/server/handlers/scheduler.ts +0 -64
- package/src/server/handlers/session.ts +0 -226
- package/src/server/handlers/settings.ts +0 -157
- package/src/server/handlers/skills.ts +0 -378
- package/src/server/handlers/terminal.ts +0 -88
- package/src/server/handlers/themes.ts +0 -121
- package/src/server/handlers/update.ts +0 -133
- package/src/server/identity.ts +0 -56
- package/src/server/index.ts +0 -457
- package/src/server/logger.ts +0 -21
- package/src/server/mesh/connector.ts +0 -419
- package/src/server/mesh/crypto.ts +0 -106
- package/src/server/mesh/discovery.ts +0 -126
- package/src/server/mesh/pairing.ts +0 -123
- package/src/server/mesh/peers.ts +0 -60
- package/src/server/mesh/proxy.ts +0 -106
- package/src/server/mesh/session-sync.ts +0 -107
- package/src/server/project/bookmarks.ts +0 -83
- package/src/server/project/context-breakdown.ts +0 -307
- package/src/server/project/file-browser.ts +0 -106
- package/src/server/project/project-files.ts +0 -267
- package/src/server/project/pty-worker.cjs +0 -83
- package/src/server/project/registry.ts +0 -57
- package/src/server/project/sdk-bridge.ts +0 -1100
- package/src/server/project/session.ts +0 -723
- package/src/server/project/terminal.ts +0 -111
- package/src/server/project/warmup.ts +0 -285
- package/src/server/push.ts +0 -121
- package/src/server/tls.ts +0 -65
- package/src/server/tui.ts +0 -103
- package/src/server/update-checker.ts +0 -147
- package/src/server/ws/broadcast.ts +0 -61
- package/src/server/ws/router.ts +0 -123
- package/src/server/ws/server.ts +0 -2
- package/src/shared/analytics.ts +0 -40
- package/src/shared/messages.ts +0 -1302
- package/src/shared/models.ts +0 -255
- package/src/shared/project-settings.ts +0 -45
- package/tsconfig.json +0 -25
- package/vite.config.ts +0 -71
- /package/{src/server/runtime.ts → dist/server/runtime.js} +0 -0
- /package/{src/shared/constants.ts → dist/shared/constants.js} +0 -0
- /package/{src/shared/index.ts → dist/shared/index.js} +0 -0
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import type { ChildProcess } from "node:child_process";
|
|
4
|
-
import { join, dirname } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
|
|
8
|
-
var __dirname_local = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
interface TerminalWorker {
|
|
11
|
-
process: ChildProcess;
|
|
12
|
-
send: (msg: object) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var terminals = new Map<string, TerminalWorker>();
|
|
16
|
-
|
|
17
|
-
var WORKER_PATH = join(__dirname_local, "pty-worker.cjs");
|
|
18
|
-
|
|
19
|
-
var NODE_MODULES_PATH = (function () {
|
|
20
|
-
try {
|
|
21
|
-
var resolved = require.resolve("node-pty");
|
|
22
|
-
var parts = resolved.split("/node_modules/");
|
|
23
|
-
parts.pop();
|
|
24
|
-
return parts.join("/node_modules/") + "/node_modules";
|
|
25
|
-
} catch {
|
|
26
|
-
return join(__dirname_local, "..", "..", "..", "node_modules");
|
|
27
|
-
}
|
|
28
|
-
})();
|
|
29
|
-
|
|
30
|
-
export function createTerminal(
|
|
31
|
-
cwd: string,
|
|
32
|
-
onData: (data: string) => void,
|
|
33
|
-
onExit: (code: number) => void,
|
|
34
|
-
): string {
|
|
35
|
-
var termId = randomUUID();
|
|
36
|
-
|
|
37
|
-
var child = spawn("node", [WORKER_PATH], {
|
|
38
|
-
stdio: ["pipe", "pipe", "ignore"],
|
|
39
|
-
cwd: cwd,
|
|
40
|
-
env: { ...process.env, NODE_PATH: NODE_MODULES_PATH },
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var buffer = "";
|
|
44
|
-
|
|
45
|
-
child.stdout!.setEncoding("utf-8");
|
|
46
|
-
child.stdout!.on("data", function (chunk: string) {
|
|
47
|
-
buffer += chunk;
|
|
48
|
-
var lines = buffer.split("\n");
|
|
49
|
-
buffer = lines.pop() || "";
|
|
50
|
-
for (var i = 0; i < lines.length; i++) {
|
|
51
|
-
if (!lines[i].trim()) continue;
|
|
52
|
-
try {
|
|
53
|
-
var msg = JSON.parse(lines[i]);
|
|
54
|
-
if (msg.type === "data") {
|
|
55
|
-
onData(msg.data);
|
|
56
|
-
} else if (msg.type === "exit") {
|
|
57
|
-
terminals.delete(termId);
|
|
58
|
-
onExit(msg.code ?? 0);
|
|
59
|
-
}
|
|
60
|
-
} catch {
|
|
61
|
-
// ignore parse errors
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
child.on("exit", function () {
|
|
67
|
-
if (terminals.has(termId)) {
|
|
68
|
-
terminals.delete(termId);
|
|
69
|
-
onExit(0);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
function sendMsg(msg: object) {
|
|
74
|
-
if (child.stdin && !child.stdin.destroyed) {
|
|
75
|
-
child.stdin.write(JSON.stringify(msg) + "\n");
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
terminals.set(termId, { process: child, send: sendMsg });
|
|
80
|
-
|
|
81
|
-
// Tell the worker to create the PTY
|
|
82
|
-
sendMsg({ type: "create", cwd: cwd, cols: 80, rows: 24 });
|
|
83
|
-
|
|
84
|
-
return termId;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function writeToTerminal(termId: string, data: string): void {
|
|
88
|
-
var worker = terminals.get(termId);
|
|
89
|
-
if (worker) {
|
|
90
|
-
worker.send({ type: "input", data: data });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function resizeTerminal(termId: string, cols: number, rows: number): void {
|
|
95
|
-
var worker = terminals.get(termId);
|
|
96
|
-
if (worker) {
|
|
97
|
-
worker.send({ type: "resize", cols: cols, rows: rows });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function destroyTerminal(termId: string): void {
|
|
102
|
-
var worker = terminals.get(termId);
|
|
103
|
-
if (worker) {
|
|
104
|
-
worker.send({ type: "kill" });
|
|
105
|
-
terminals.delete(termId);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function getTerminal(termId: string): TerminalWorker | undefined {
|
|
110
|
-
return terminals.get(termId);
|
|
111
|
-
}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import type { AccountInfo } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
-
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
-
import { broadcast } from "../ws/broadcast";
|
|
4
|
-
import { log } from "../logger";
|
|
5
|
-
import { loadConfig } from "../config";
|
|
6
|
-
import { listSessions, loadSessionHistory } from "./session";
|
|
7
|
-
import { execSync } from "node:child_process";
|
|
8
|
-
import { existsSync, unlinkSync, rmSync } from "node:fs";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
import { homedir } from "node:os";
|
|
11
|
-
|
|
12
|
-
var claudeExePath: string | null = null;
|
|
13
|
-
|
|
14
|
-
function getClaudeExecutablePath(): string {
|
|
15
|
-
if (claudeExePath) return claudeExePath;
|
|
16
|
-
try {
|
|
17
|
-
claudeExePath = execSync("which claude", { encoding: "utf-8" }).trim();
|
|
18
|
-
} catch {
|
|
19
|
-
claudeExePath = "claude";
|
|
20
|
-
}
|
|
21
|
-
return claudeExePath;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ModelEntry {
|
|
25
|
-
value: string;
|
|
26
|
-
displayName: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var KNOWN_MODELS: ModelEntry[] = [
|
|
30
|
-
{ value: "default", displayName: "Default" },
|
|
31
|
-
{ value: "opus", displayName: "Opus" },
|
|
32
|
-
{ value: "sonnet", displayName: "Sonnet" },
|
|
33
|
-
{ value: "haiku", displayName: "Haiku" },
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
var warmupModels: ModelEntry[] = [];
|
|
37
|
-
var warmupSlashCommands: string[] = [];
|
|
38
|
-
var warmupAccountInfo: AccountInfo | null = null;
|
|
39
|
-
var warmupComplete = false;
|
|
40
|
-
|
|
41
|
-
interface WarmupRateLimitEntry {
|
|
42
|
-
status: string;
|
|
43
|
-
utilization?: number;
|
|
44
|
-
resetsAt?: number;
|
|
45
|
-
rateLimitType?: string;
|
|
46
|
-
overageStatus?: string;
|
|
47
|
-
overageResetsAt?: number;
|
|
48
|
-
isUsingOverage?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var warmupRateLimits: Map<string, WarmupRateLimitEntry> = new Map();
|
|
52
|
-
|
|
53
|
-
function ensureKnownModels(sdkModels: ModelEntry[]): ModelEntry[] {
|
|
54
|
-
var seen = new Set<string>();
|
|
55
|
-
for (var i = 0; i < sdkModels.length; i++) {
|
|
56
|
-
seen.add(sdkModels[i].value);
|
|
57
|
-
}
|
|
58
|
-
var result = sdkModels.slice();
|
|
59
|
-
for (var j = 0; j < KNOWN_MODELS.length; j++) {
|
|
60
|
-
if (!seen.has(KNOWN_MODELS[j].value)) {
|
|
61
|
-
result.push(KNOWN_MODELS[j]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function deleteWarmupSession(cwd: string, sessionId: string | null): void {
|
|
68
|
-
if (!sessionId) return;
|
|
69
|
-
try {
|
|
70
|
-
var hash = cwd.replace(/\//g, "-");
|
|
71
|
-
var projectDir = join(homedir(), ".claude", "projects", hash);
|
|
72
|
-
var jsonlPath = join(projectDir, sessionId + ".jsonl");
|
|
73
|
-
var dirPath = join(projectDir, sessionId);
|
|
74
|
-
if (existsSync(jsonlPath)) {
|
|
75
|
-
unlinkSync(jsonlPath);
|
|
76
|
-
log.server("Deleted warmup session file: %s", sessionId);
|
|
77
|
-
}
|
|
78
|
-
if (existsSync(dirPath)) {
|
|
79
|
-
rmSync(dirPath, { recursive: true, force: true });
|
|
80
|
-
}
|
|
81
|
-
} catch (err) {
|
|
82
|
-
log.server("Failed to delete warmup session: %O", err);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function runWarmup(cwd: string): Promise<void> {
|
|
87
|
-
log.server("SDK warmup starting (cwd: %s)...", cwd);
|
|
88
|
-
try {
|
|
89
|
-
var ac = new AbortController();
|
|
90
|
-
var ended = false;
|
|
91
|
-
var WARMUP_SESSION_ID = "lattice-warmup";
|
|
92
|
-
|
|
93
|
-
var mq = {
|
|
94
|
-
[Symbol.asyncIterator]: function () {
|
|
95
|
-
return {
|
|
96
|
-
next: function () {
|
|
97
|
-
if (ended) return Promise.resolve({ value: undefined as any, done: true });
|
|
98
|
-
ended = true;
|
|
99
|
-
return Promise.resolve({
|
|
100
|
-
value: {
|
|
101
|
-
type: "user" as const,
|
|
102
|
-
message: { role: "user" as const, content: [{ type: "text" as const, text: "hi" }] },
|
|
103
|
-
parent_tool_use_id: null,
|
|
104
|
-
session_id: WARMUP_SESSION_ID,
|
|
105
|
-
},
|
|
106
|
-
done: false,
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var stream = query({
|
|
114
|
-
prompt: mq as any,
|
|
115
|
-
options: {
|
|
116
|
-
cwd,
|
|
117
|
-
sessionId: WARMUP_SESSION_ID,
|
|
118
|
-
settingSources: ["user", "project", "local"],
|
|
119
|
-
abortController: ac,
|
|
120
|
-
permissionMode: "plan",
|
|
121
|
-
pathToClaudeCodeExecutable: getClaudeExecutablePath(),
|
|
122
|
-
stderr: function (data: string) {
|
|
123
|
-
log.server("Warmup stderr: %s", data.trim());
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
for await (var msg of stream) {
|
|
129
|
-
if (msg.type === "system") {
|
|
130
|
-
var sysMsg = msg as any;
|
|
131
|
-
if (sysMsg.subtype === "init") {
|
|
132
|
-
if (sysMsg.slash_commands) {
|
|
133
|
-
warmupSlashCommands = sysMsg.slash_commands;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
var models = await stream.supportedModels();
|
|
138
|
-
warmupModels = ensureKnownModels((models || []) as ModelEntry[]);
|
|
139
|
-
} catch {
|
|
140
|
-
warmupModels = KNOWN_MODELS.slice();
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
warmupAccountInfo = await stream.accountInfo();
|
|
145
|
-
} catch {}
|
|
146
|
-
|
|
147
|
-
ac.abort();
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (msg.type === "rate_limit_event") {
|
|
153
|
-
var rlMsg = msg as { type: string; rate_limit_info: { status: string; utilization?: number; resetsAt?: number; rateLimitType?: string; overageStatus?: string; overageResetsAt?: number; isUsingOverage?: boolean } };
|
|
154
|
-
var rli = rlMsg.rate_limit_info;
|
|
155
|
-
var cacheKey = rli.rateLimitType || "default";
|
|
156
|
-
warmupRateLimits.set(cacheKey, {
|
|
157
|
-
status: rli.status,
|
|
158
|
-
utilization: rli.utilization,
|
|
159
|
-
resetsAt: rli.resetsAt,
|
|
160
|
-
rateLimitType: rli.rateLimitType,
|
|
161
|
-
overageStatus: rli.overageStatus,
|
|
162
|
-
overageResetsAt: rli.overageResetsAt,
|
|
163
|
-
isUsingOverage: rli.isUsingOverage,
|
|
164
|
-
});
|
|
165
|
-
broadcast({
|
|
166
|
-
type: "chat:rate_limit",
|
|
167
|
-
status: rli.status,
|
|
168
|
-
utilization: rli.utilization,
|
|
169
|
-
resetsAt: rli.resetsAt,
|
|
170
|
-
rateLimitType: rli.rateLimitType,
|
|
171
|
-
overageStatus: rli.overageStatus,
|
|
172
|
-
overageResetsAt: rli.overageResetsAt,
|
|
173
|
-
isUsingOverage: rli.isUsingOverage,
|
|
174
|
-
} as any);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
warmupComplete = true;
|
|
179
|
-
deleteWarmupSession(cwd, WARMUP_SESSION_ID);
|
|
180
|
-
log.server("SDK warmup complete: %d models, %d commands, auth=%s",
|
|
181
|
-
warmupModels.length, warmupSlashCommands.length,
|
|
182
|
-
warmupAccountInfo?.apiKeySource || "unknown");
|
|
183
|
-
if (warmupAccountInfo) {
|
|
184
|
-
log.server("Account: email=%s org=%s subscription=%s provider=%s source=%s",
|
|
185
|
-
warmupAccountInfo.email || "none",
|
|
186
|
-
warmupAccountInfo.organization || "none",
|
|
187
|
-
warmupAccountInfo.subscriptionType || "none",
|
|
188
|
-
warmupAccountInfo.apiProvider || "none",
|
|
189
|
-
warmupAccountInfo.apiKeySource || "none");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
broadcast({
|
|
193
|
-
type: "warmup:models",
|
|
194
|
-
models: warmupModels,
|
|
195
|
-
} as any);
|
|
196
|
-
|
|
197
|
-
if (warmupAccountInfo) {
|
|
198
|
-
broadcast({
|
|
199
|
-
type: "warmup:account",
|
|
200
|
-
email: warmupAccountInfo.email,
|
|
201
|
-
organization: warmupAccountInfo.organization,
|
|
202
|
-
subscriptionType: warmupAccountInfo.subscriptionType,
|
|
203
|
-
apiKeySource: warmupAccountInfo.apiKeySource,
|
|
204
|
-
apiProvider: warmupAccountInfo.apiProvider,
|
|
205
|
-
} as any);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
void warmupProjectData();
|
|
209
|
-
} catch (err) {
|
|
210
|
-
if (err && (err as any).name !== "AbortError" && !(err instanceof Error && err.message.includes("aborted"))) {
|
|
211
|
-
log.server("SDK warmup failed: %O", err);
|
|
212
|
-
}
|
|
213
|
-
warmupModels = KNOWN_MODELS.slice();
|
|
214
|
-
warmupComplete = true;
|
|
215
|
-
void warmupProjectData();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async function warmupProjectData(): Promise<void> {
|
|
220
|
-
var t0 = Date.now();
|
|
221
|
-
var config = loadConfig();
|
|
222
|
-
var projects = config.projects;
|
|
223
|
-
if (projects.length === 0) return;
|
|
224
|
-
|
|
225
|
-
log.server("Data warmup: pre-caching %d project(s)...", projects.length);
|
|
226
|
-
|
|
227
|
-
var totalSessions = 0;
|
|
228
|
-
var recentSessionIds: Array<{ projectSlug: string; sessionId: string }> = [];
|
|
229
|
-
|
|
230
|
-
for (var i = 0; i < projects.length; i++) {
|
|
231
|
-
try {
|
|
232
|
-
var result = await listSessions(projects[i].slug, { limit: 40 });
|
|
233
|
-
totalSessions += result.sessions.length;
|
|
234
|
-
broadcast({
|
|
235
|
-
type: "session:list",
|
|
236
|
-
projectSlug: projects[i].slug,
|
|
237
|
-
sessions: result.sessions,
|
|
238
|
-
totalCount: result.totalCount,
|
|
239
|
-
} as any);
|
|
240
|
-
var preWarmCount = Math.min(5, result.sessions.length);
|
|
241
|
-
for (var k = 0; k < preWarmCount; k++) {
|
|
242
|
-
recentSessionIds.push({
|
|
243
|
-
projectSlug: projects[i].slug,
|
|
244
|
-
sessionId: result.sessions[k].id,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
} catch {}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
log.server("Data warmup: cached %d sessions across %d projects (%dms)", totalSessions, projects.length, Date.now() - t0);
|
|
251
|
-
|
|
252
|
-
for (var j = 0; j < recentSessionIds.length; j++) {
|
|
253
|
-
try {
|
|
254
|
-
await loadSessionHistory(recentSessionIds[j].projectSlug, recentSessionIds[j].sessionId);
|
|
255
|
-
} catch {}
|
|
256
|
-
}
|
|
257
|
-
if (recentSessionIds.length > 0) {
|
|
258
|
-
log.server("Data warmup: pre-cached history for %d recent sessions (%dms)", recentSessionIds.length, Date.now() - t0);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export function getWarmupModels(): ModelEntry[] {
|
|
263
|
-
return warmupModels.length > 0 ? warmupModels : KNOWN_MODELS.slice();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export function getWarmupSlashCommands(): string[] {
|
|
267
|
-
return warmupSlashCommands;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export function getWarmupAccountInfo(): AccountInfo | null {
|
|
271
|
-
return warmupAccountInfo;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export function getWarmupRateLimits(): WarmupRateLimitEntry[] {
|
|
275
|
-
return Array.from(warmupRateLimits.values());
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export function cacheRateLimitEntry(entry: WarmupRateLimitEntry): void {
|
|
279
|
-
var key = entry.rateLimitType || "default";
|
|
280
|
-
warmupRateLimits.set(key, entry);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export function isWarmupComplete(): boolean {
|
|
284
|
-
return warmupComplete;
|
|
285
|
-
}
|
package/src/server/push.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import webpush from "web-push";
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { getLatticeHome } from "./config";
|
|
5
|
-
import { log } from "./logger";
|
|
6
|
-
|
|
7
|
-
interface VapidKeys {
|
|
8
|
-
publicKey: string;
|
|
9
|
-
privateKey: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface PushSubscription {
|
|
13
|
-
endpoint: string;
|
|
14
|
-
keys: {
|
|
15
|
-
p256dh: string;
|
|
16
|
-
auth: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var vapidKeys: VapidKeys | null = null;
|
|
21
|
-
var subscriptions = new Map<string, PushSubscription>();
|
|
22
|
-
|
|
23
|
-
function getVapidPath(): string {
|
|
24
|
-
return join(getLatticeHome(), "vapid.json");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getSubscriptionsPath(): string {
|
|
28
|
-
return join(getLatticeHome(), "push-subs.json");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function ensureVapidKeys(): VapidKeys {
|
|
32
|
-
if (vapidKeys) return vapidKeys;
|
|
33
|
-
|
|
34
|
-
var vapidPath = getVapidPath();
|
|
35
|
-
if (existsSync(vapidPath)) {
|
|
36
|
-
try {
|
|
37
|
-
vapidKeys = JSON.parse(readFileSync(vapidPath, "utf-8"));
|
|
38
|
-
if (vapidKeys) return vapidKeys;
|
|
39
|
-
} catch {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var generated = webpush.generateVAPIDKeys();
|
|
43
|
-
vapidKeys = {
|
|
44
|
-
publicKey: generated.publicKey,
|
|
45
|
-
privateKey: generated.privateKey,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var dir = getLatticeHome();
|
|
49
|
-
if (!existsSync(dir)) {
|
|
50
|
-
mkdirSync(dir, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
writeFileSync(vapidPath, JSON.stringify(vapidKeys, null, 2), "utf-8");
|
|
53
|
-
log.server("Generated VAPID keys for push notifications");
|
|
54
|
-
return vapidKeys;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function loadSubscriptions(): void {
|
|
58
|
-
var subsPath = getSubscriptionsPath();
|
|
59
|
-
if (!existsSync(subsPath)) return;
|
|
60
|
-
try {
|
|
61
|
-
var data = JSON.parse(readFileSync(subsPath, "utf-8")) as PushSubscription[];
|
|
62
|
-
for (var i = 0; i < data.length; i++) {
|
|
63
|
-
subscriptions.set(data[i].endpoint, data[i]);
|
|
64
|
-
}
|
|
65
|
-
} catch {}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function saveSubscriptions(): void {
|
|
69
|
-
var arr: PushSubscription[] = [];
|
|
70
|
-
subscriptions.forEach(function (sub) {
|
|
71
|
-
arr.push(sub);
|
|
72
|
-
});
|
|
73
|
-
writeFileSync(getSubscriptionsPath(), JSON.stringify(arr), "utf-8");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function initPush(): void {
|
|
77
|
-
var keys = ensureVapidKeys();
|
|
78
|
-
webpush.setVapidDetails(
|
|
79
|
-
"mailto:lattice@localhost",
|
|
80
|
-
keys.publicKey,
|
|
81
|
-
keys.privateKey,
|
|
82
|
-
);
|
|
83
|
-
loadSubscriptions();
|
|
84
|
-
log.server("Push notifications ready (%d subscription(s))", subscriptions.size);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function getVapidPublicKey(): string {
|
|
88
|
-
return ensureVapidKeys().publicKey;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function addPushSubscription(sub: PushSubscription): void {
|
|
92
|
-
subscriptions.set(sub.endpoint, sub);
|
|
93
|
-
saveSubscriptions();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function removePushSubscription(endpoint: string): void {
|
|
97
|
-
subscriptions.delete(endpoint);
|
|
98
|
-
saveSubscriptions();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface PushPayload {
|
|
102
|
-
type: "done" | "permission_request" | "elicitation" | "error";
|
|
103
|
-
title: string;
|
|
104
|
-
body: string;
|
|
105
|
-
sessionId?: string;
|
|
106
|
-
projectSlug?: string;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function sendPush(payload: PushPayload): void {
|
|
110
|
-
if (subscriptions.size === 0) return;
|
|
111
|
-
|
|
112
|
-
var json = JSON.stringify(payload);
|
|
113
|
-
subscriptions.forEach(function (sub, endpoint) {
|
|
114
|
-
webpush.sendNotification(sub, json).catch(function (err: { statusCode?: number }) {
|
|
115
|
-
if (err.statusCode === 410 || err.statusCode === 404 || err.statusCode === 403) {
|
|
116
|
-
subscriptions.delete(endpoint);
|
|
117
|
-
saveSubscriptions();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
package/src/server/tls.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { getLatticeHome } from "./config";
|
|
5
|
-
|
|
6
|
-
export interface CertPaths {
|
|
7
|
-
cert: string;
|
|
8
|
-
key: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getCertsDir(): string {
|
|
12
|
-
var certsDir = join(getLatticeHome(), "certs");
|
|
13
|
-
if (!existsSync(certsDir)) {
|
|
14
|
-
mkdirSync(certsDir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
return certsDir;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function isCertExpiringSoon(certPath: string): boolean {
|
|
20
|
-
try {
|
|
21
|
-
var result = spawnSync("openssl", ["x509", "-enddate", "-noout", "-in", certPath], { encoding: "utf-8" });
|
|
22
|
-
if (result.status !== 0) return true;
|
|
23
|
-
var match = result.stdout.match(/notAfter=(.+)/);
|
|
24
|
-
if (!match) return true;
|
|
25
|
-
var expiryDate = new Date(match[1]);
|
|
26
|
-
var daysLeft = (expiryDate.getTime() - Date.now()) / (1000 * 60 * 60 * 24);
|
|
27
|
-
return daysLeft < 30;
|
|
28
|
-
} catch {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function ensureCerts(): CertPaths {
|
|
34
|
-
var certsDir = getCertsDir();
|
|
35
|
-
var certPath = join(certsDir, "cert.pem");
|
|
36
|
-
var keyPath = join(certsDir, "key.pem");
|
|
37
|
-
|
|
38
|
-
if (existsSync(certPath) && existsSync(keyPath) && !isCertExpiringSoon(certPath)) {
|
|
39
|
-
return { cert: certPath, key: keyPath };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
console.log("[lattice] Generating self-signed TLS certificate...");
|
|
43
|
-
|
|
44
|
-
var result = spawnSync(
|
|
45
|
-
"openssl",
|
|
46
|
-
[
|
|
47
|
-
"req", "-x509",
|
|
48
|
-
"-newkey", "rsa:2048",
|
|
49
|
-
"-keyout", keyPath,
|
|
50
|
-
"-out", certPath,
|
|
51
|
-
"-days", "365",
|
|
52
|
-
"-nodes",
|
|
53
|
-
"-subj", "/CN=lattice",
|
|
54
|
-
],
|
|
55
|
-
{ encoding: "utf-8" }
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
if (result.status !== 0) {
|
|
59
|
-
throw new Error("[lattice] Failed to generate TLS certificates: " + (result.stderr || result.error?.message || "unknown error"));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.log("[lattice] TLS certificates generated at " + certsDir);
|
|
63
|
-
|
|
64
|
-
return { cert: certPath, key: keyPath };
|
|
65
|
-
}
|
package/src/server/tui.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import * as p from "@clack/prompts";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { getLatticeHome, loadConfig, saveConfig } from "./config";
|
|
5
|
-
import type { LatticeConfig } from "#shared";
|
|
6
|
-
import { DEFAULT_PORT } from "#shared";
|
|
7
|
-
|
|
8
|
-
var BANNER = `
|
|
9
|
-
\x1b[36m██╗\x1b[0m \x1b[36m█████╗\x1b[0m \x1b[36m████████╗████████╗██╗\x1b[0m \x1b[36m██████╗\x1b[0m \x1b[36m███████╗\x1b[0m
|
|
10
|
-
\x1b[36m██║\x1b[0m \x1b[36m██╔══██╗\x1b[0m\x1b[2m╚══\x1b[0m\x1b[36m██\x1b[0m\x1b[2m╔══╝╚══\x1b[0m\x1b[36m██\x1b[0m\x1b[2m╔══╝\x1b[0m\x1b[36m██║\x1b[0m\x1b[36m██╔════╝\x1b[0m\x1b[36m██╔════╝\x1b[0m
|
|
11
|
-
\x1b[36m██║\x1b[0m \x1b[36m███████║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║██║\x1b[0m \x1b[36m█████╗\x1b[0m
|
|
12
|
-
\x1b[36m██║\x1b[0m \x1b[36m██╔══██║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║██║\x1b[0m \x1b[36m██╔══╝\x1b[0m
|
|
13
|
-
\x1b[36m███████╗██║ ██║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║\x1b[0m \x1b[36m██║\x1b[0m\x1b[2m╚\x1b[0m\x1b[36m██████╗███████╗\x1b[0m
|
|
14
|
-
\x1b[2m╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝\x1b[0m
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
export function printBanner(): void {
|
|
18
|
-
console.log(BANNER);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function printStatus(config: LatticeConfig, version: string, projectCount: number, sessionCount: number): void {
|
|
22
|
-
var protocol = config.tls ? "https" : "http";
|
|
23
|
-
var url = protocol + "://localhost:" + config.port;
|
|
24
|
-
|
|
25
|
-
console.log("");
|
|
26
|
-
p.note(
|
|
27
|
-
"lattice v" + version + " — " + url + "\n" +
|
|
28
|
-
projectCount + " project" + (projectCount !== 1 ? "s" : "") +
|
|
29
|
-
" · " + sessionCount + " session" + (sessionCount !== 1 ? "s" : "") + "\n" +
|
|
30
|
-
"Press Ctrl+C to stop",
|
|
31
|
-
"Running"
|
|
32
|
-
);
|
|
33
|
-
console.log("");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function printQrCode(url: string): Promise<void> {
|
|
37
|
-
try {
|
|
38
|
-
var qrcode = await import("qrcode");
|
|
39
|
-
var qr = await (qrcode as any).toString(url, {
|
|
40
|
-
type: "terminal",
|
|
41
|
-
small: true,
|
|
42
|
-
});
|
|
43
|
-
console.log(qr);
|
|
44
|
-
console.log(" \x1b[2m" + url + "\x1b[0m");
|
|
45
|
-
console.log("");
|
|
46
|
-
} catch {
|
|
47
|
-
console.log(" " + url);
|
|
48
|
-
console.log("");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function runOnboarding(): Promise<{ port: number; passphrase: string | null }> {
|
|
53
|
-
var configPath = join(getLatticeHome(), "config.json");
|
|
54
|
-
var isFirstRun = !existsSync(configPath);
|
|
55
|
-
|
|
56
|
-
if (!isFirstRun) {
|
|
57
|
-
var config = loadConfig();
|
|
58
|
-
return { port: config.port, passphrase: null };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
printBanner();
|
|
62
|
-
|
|
63
|
-
p.intro("Welcome to Lattice");
|
|
64
|
-
|
|
65
|
-
p.note(
|
|
66
|
-
"Anyone with the URL gets full Claude Code access to this machine.\n" +
|
|
67
|
-
"Use a private network (Tailscale, VPN) or set a passphrase.",
|
|
68
|
-
"Security"
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
var portResult = await p.text({
|
|
72
|
-
message: "Port",
|
|
73
|
-
placeholder: String(DEFAULT_PORT),
|
|
74
|
-
defaultValue: String(DEFAULT_PORT),
|
|
75
|
-
validate: function (val: string | undefined) {
|
|
76
|
-
var n = parseInt(val || "", 10);
|
|
77
|
-
if (isNaN(n) || n < 1 || n > 65535) return "Enter a valid port (1-65535)";
|
|
78
|
-
return undefined;
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
if (p.isCancel(portResult)) {
|
|
82
|
-
p.cancel("Setup cancelled");
|
|
83
|
-
process.exit(0);
|
|
84
|
-
}
|
|
85
|
-
var port = parseInt(portResult as string, 10);
|
|
86
|
-
|
|
87
|
-
var passphraseResult = await p.password({
|
|
88
|
-
message: "Passphrase (optional, press Enter to skip)",
|
|
89
|
-
});
|
|
90
|
-
if (p.isCancel(passphraseResult)) {
|
|
91
|
-
p.cancel("Setup cancelled");
|
|
92
|
-
process.exit(0);
|
|
93
|
-
}
|
|
94
|
-
var passphrase = (passphraseResult as string) || null;
|
|
95
|
-
|
|
96
|
-
p.outro("Setup complete");
|
|
97
|
-
|
|
98
|
-
var config = loadConfig();
|
|
99
|
-
config.port = port;
|
|
100
|
-
saveConfig(config);
|
|
101
|
-
|
|
102
|
-
return { port, passphrase };
|
|
103
|
-
}
|