@cryptiklemur/lattice 4.0.2 → 5.0.1
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 +533 -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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
var __dirname_local = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
var terminals = new Map();
|
|
7
|
+
var WORKER_PATH = join(__dirname_local, "pty-worker.cjs");
|
|
8
|
+
var NODE_MODULES_PATH = (function () {
|
|
9
|
+
try {
|
|
10
|
+
var resolved = require.resolve("node-pty");
|
|
11
|
+
var parts = resolved.split("/node_modules/");
|
|
12
|
+
parts.pop();
|
|
13
|
+
return parts.join("/node_modules/") + "/node_modules";
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return join(__dirname_local, "..", "..", "..", "node_modules");
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
export function createTerminal(cwd, onData, onExit) {
|
|
20
|
+
var termId = randomUUID();
|
|
21
|
+
var child = spawn("node", [WORKER_PATH], {
|
|
22
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
23
|
+
cwd: cwd,
|
|
24
|
+
env: { ...process.env, NODE_PATH: NODE_MODULES_PATH },
|
|
25
|
+
});
|
|
26
|
+
var buffer = "";
|
|
27
|
+
child.stdout.setEncoding("utf-8");
|
|
28
|
+
child.stdout.on("data", function (chunk) {
|
|
29
|
+
buffer += chunk;
|
|
30
|
+
var lines = buffer.split("\n");
|
|
31
|
+
buffer = lines.pop() || "";
|
|
32
|
+
for (var i = 0; i < lines.length; i++) {
|
|
33
|
+
if (!lines[i].trim())
|
|
34
|
+
continue;
|
|
35
|
+
try {
|
|
36
|
+
var msg = JSON.parse(lines[i]);
|
|
37
|
+
if (msg.type === "data") {
|
|
38
|
+
onData(msg.data);
|
|
39
|
+
}
|
|
40
|
+
else if (msg.type === "exit") {
|
|
41
|
+
terminals.delete(termId);
|
|
42
|
+
onExit(msg.code ?? 0);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// ignore parse errors
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
child.on("exit", function () {
|
|
51
|
+
if (terminals.has(termId)) {
|
|
52
|
+
terminals.delete(termId);
|
|
53
|
+
onExit(0);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
function sendMsg(msg) {
|
|
57
|
+
if (child.stdin && !child.stdin.destroyed) {
|
|
58
|
+
child.stdin.write(JSON.stringify(msg) + "\n");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
terminals.set(termId, { process: child, send: sendMsg });
|
|
62
|
+
// Tell the worker to create the PTY
|
|
63
|
+
sendMsg({ type: "create", cwd: cwd, cols: 80, rows: 24 });
|
|
64
|
+
return termId;
|
|
65
|
+
}
|
|
66
|
+
export function writeToTerminal(termId, data) {
|
|
67
|
+
var worker = terminals.get(termId);
|
|
68
|
+
if (worker) {
|
|
69
|
+
worker.send({ type: "input", data: data });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function resizeTerminal(termId, cols, rows) {
|
|
73
|
+
var worker = terminals.get(termId);
|
|
74
|
+
if (worker) {
|
|
75
|
+
worker.send({ type: "resize", cols: cols, rows: rows });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function destroyTerminal(termId) {
|
|
79
|
+
var worker = terminals.get(termId);
|
|
80
|
+
if (worker) {
|
|
81
|
+
worker.send({ type: "kill" });
|
|
82
|
+
terminals.delete(termId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function getTerminal(termId) {
|
|
86
|
+
return terminals.get(termId);
|
|
87
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import { broadcast } from "../ws/broadcast.js";
|
|
3
|
+
import { log } from "../logger.js";
|
|
4
|
+
import { loadConfig } from "../config.js";
|
|
5
|
+
import { listSessions, loadSessionHistory } from "./session.js";
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
import { existsSync, unlinkSync, rmSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
var claudeExePath = null;
|
|
11
|
+
function getClaudeExecutablePath() {
|
|
12
|
+
if (claudeExePath)
|
|
13
|
+
return claudeExePath;
|
|
14
|
+
try {
|
|
15
|
+
claudeExePath = execSync("which claude", { encoding: "utf-8" }).trim();
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
claudeExePath = "claude";
|
|
19
|
+
}
|
|
20
|
+
return claudeExePath;
|
|
21
|
+
}
|
|
22
|
+
var KNOWN_MODELS = [
|
|
23
|
+
{ value: "default", displayName: "Default" },
|
|
24
|
+
{ value: "opus", displayName: "Opus" },
|
|
25
|
+
{ value: "sonnet", displayName: "Sonnet" },
|
|
26
|
+
{ value: "haiku", displayName: "Haiku" },
|
|
27
|
+
];
|
|
28
|
+
var warmupModels = [];
|
|
29
|
+
var warmupSlashCommands = [];
|
|
30
|
+
var warmupAccountInfo = null;
|
|
31
|
+
var warmupComplete = false;
|
|
32
|
+
var warmupRateLimits = new Map();
|
|
33
|
+
function ensureKnownModels(sdkModels) {
|
|
34
|
+
var seen = new Set();
|
|
35
|
+
for (var i = 0; i < sdkModels.length; i++) {
|
|
36
|
+
seen.add(sdkModels[i].value);
|
|
37
|
+
}
|
|
38
|
+
var result = sdkModels.slice();
|
|
39
|
+
for (var j = 0; j < KNOWN_MODELS.length; j++) {
|
|
40
|
+
if (!seen.has(KNOWN_MODELS[j].value)) {
|
|
41
|
+
result.push(KNOWN_MODELS[j]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function deleteWarmupSession(cwd, sessionId) {
|
|
47
|
+
if (!sessionId)
|
|
48
|
+
return;
|
|
49
|
+
try {
|
|
50
|
+
var hash = cwd.replace(/\//g, "-");
|
|
51
|
+
var projectDir = join(homedir(), ".claude", "projects", hash);
|
|
52
|
+
var jsonlPath = join(projectDir, sessionId + ".jsonl");
|
|
53
|
+
var dirPath = join(projectDir, sessionId);
|
|
54
|
+
if (existsSync(jsonlPath)) {
|
|
55
|
+
unlinkSync(jsonlPath);
|
|
56
|
+
log.server("Deleted warmup session file: %s", sessionId);
|
|
57
|
+
}
|
|
58
|
+
if (existsSync(dirPath)) {
|
|
59
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
log.server("Failed to delete warmup session: %O", err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function runWarmup(cwd) {
|
|
67
|
+
log.server("SDK warmup starting (cwd: %s)...", cwd);
|
|
68
|
+
try {
|
|
69
|
+
var ac = new AbortController();
|
|
70
|
+
var ended = false;
|
|
71
|
+
var WARMUP_SESSION_ID = "lattice-warmup";
|
|
72
|
+
var mq = {
|
|
73
|
+
[Symbol.asyncIterator]: function () {
|
|
74
|
+
return {
|
|
75
|
+
next: function () {
|
|
76
|
+
if (ended)
|
|
77
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
78
|
+
ended = true;
|
|
79
|
+
return Promise.resolve({
|
|
80
|
+
value: {
|
|
81
|
+
type: "user",
|
|
82
|
+
message: { role: "user", content: [{ type: "text", text: "hi" }] },
|
|
83
|
+
parent_tool_use_id: null,
|
|
84
|
+
session_id: WARMUP_SESSION_ID,
|
|
85
|
+
},
|
|
86
|
+
done: false,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
var stream = query({
|
|
93
|
+
prompt: mq,
|
|
94
|
+
options: {
|
|
95
|
+
cwd,
|
|
96
|
+
sessionId: WARMUP_SESSION_ID,
|
|
97
|
+
settingSources: ["user", "project", "local"],
|
|
98
|
+
abortController: ac,
|
|
99
|
+
permissionMode: "plan",
|
|
100
|
+
pathToClaudeCodeExecutable: getClaudeExecutablePath(),
|
|
101
|
+
stderr: function (data) {
|
|
102
|
+
log.server("Warmup stderr: %s", data.trim());
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
for await (var msg of stream) {
|
|
107
|
+
if (msg.type === "system") {
|
|
108
|
+
var sysMsg = msg;
|
|
109
|
+
if (sysMsg.subtype === "init") {
|
|
110
|
+
if (sysMsg.slash_commands) {
|
|
111
|
+
warmupSlashCommands = sysMsg.slash_commands;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
var models = await stream.supportedModels();
|
|
115
|
+
warmupModels = ensureKnownModels((models || []));
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
warmupModels = KNOWN_MODELS.slice();
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
warmupAccountInfo = await stream.accountInfo();
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
ac.abort();
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (msg.type === "rate_limit_event") {
|
|
129
|
+
var rlMsg = msg;
|
|
130
|
+
var rli = rlMsg.rate_limit_info;
|
|
131
|
+
var cacheKey = rli.rateLimitType || "default";
|
|
132
|
+
warmupRateLimits.set(cacheKey, {
|
|
133
|
+
status: rli.status,
|
|
134
|
+
utilization: rli.utilization,
|
|
135
|
+
resetsAt: rli.resetsAt,
|
|
136
|
+
rateLimitType: rli.rateLimitType,
|
|
137
|
+
overageStatus: rli.overageStatus,
|
|
138
|
+
overageResetsAt: rli.overageResetsAt,
|
|
139
|
+
isUsingOverage: rli.isUsingOverage,
|
|
140
|
+
});
|
|
141
|
+
broadcast({
|
|
142
|
+
type: "chat:rate_limit",
|
|
143
|
+
status: rli.status,
|
|
144
|
+
utilization: rli.utilization,
|
|
145
|
+
resetsAt: rli.resetsAt,
|
|
146
|
+
rateLimitType: rli.rateLimitType,
|
|
147
|
+
overageStatus: rli.overageStatus,
|
|
148
|
+
overageResetsAt: rli.overageResetsAt,
|
|
149
|
+
isUsingOverage: rli.isUsingOverage,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
warmupComplete = true;
|
|
154
|
+
deleteWarmupSession(cwd, WARMUP_SESSION_ID);
|
|
155
|
+
log.server("SDK warmup complete: %d models, %d commands, auth=%s", warmupModels.length, warmupSlashCommands.length, warmupAccountInfo?.apiKeySource || "unknown");
|
|
156
|
+
if (warmupAccountInfo) {
|
|
157
|
+
log.server("Account: email=%s org=%s subscription=%s provider=%s source=%s", warmupAccountInfo.email || "none", warmupAccountInfo.organization || "none", warmupAccountInfo.subscriptionType || "none", warmupAccountInfo.apiProvider || "none", warmupAccountInfo.apiKeySource || "none");
|
|
158
|
+
}
|
|
159
|
+
broadcast({
|
|
160
|
+
type: "warmup:models",
|
|
161
|
+
models: warmupModels,
|
|
162
|
+
});
|
|
163
|
+
if (warmupAccountInfo) {
|
|
164
|
+
broadcast({
|
|
165
|
+
type: "warmup:account",
|
|
166
|
+
email: warmupAccountInfo.email,
|
|
167
|
+
organization: warmupAccountInfo.organization,
|
|
168
|
+
subscriptionType: warmupAccountInfo.subscriptionType,
|
|
169
|
+
apiKeySource: warmupAccountInfo.apiKeySource,
|
|
170
|
+
apiProvider: warmupAccountInfo.apiProvider,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
void warmupProjectData();
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
if (err && err.name !== "AbortError" && !(err instanceof Error && err.message.includes("aborted"))) {
|
|
177
|
+
log.server("SDK warmup failed: %O", err);
|
|
178
|
+
}
|
|
179
|
+
warmupModels = KNOWN_MODELS.slice();
|
|
180
|
+
warmupComplete = true;
|
|
181
|
+
void warmupProjectData();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function warmupProjectData() {
|
|
185
|
+
var t0 = Date.now();
|
|
186
|
+
var config = loadConfig();
|
|
187
|
+
var projects = config.projects;
|
|
188
|
+
if (projects.length === 0)
|
|
189
|
+
return;
|
|
190
|
+
log.server("Data warmup: pre-caching %d project(s)...", projects.length);
|
|
191
|
+
var totalSessions = 0;
|
|
192
|
+
var recentSessionIds = [];
|
|
193
|
+
for (var i = 0; i < projects.length; i++) {
|
|
194
|
+
try {
|
|
195
|
+
var result = await listSessions(projects[i].slug, { limit: 40 });
|
|
196
|
+
totalSessions += result.sessions.length;
|
|
197
|
+
broadcast({
|
|
198
|
+
type: "session:list",
|
|
199
|
+
projectSlug: projects[i].slug,
|
|
200
|
+
sessions: result.sessions,
|
|
201
|
+
totalCount: result.totalCount,
|
|
202
|
+
});
|
|
203
|
+
var preWarmCount = Math.min(5, result.sessions.length);
|
|
204
|
+
for (var k = 0; k < preWarmCount; k++) {
|
|
205
|
+
recentSessionIds.push({
|
|
206
|
+
projectSlug: projects[i].slug,
|
|
207
|
+
sessionId: result.sessions[k].id,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch { }
|
|
212
|
+
}
|
|
213
|
+
log.server("Data warmup: cached %d sessions across %d projects (%dms)", totalSessions, projects.length, Date.now() - t0);
|
|
214
|
+
for (var j = 0; j < recentSessionIds.length; j++) {
|
|
215
|
+
try {
|
|
216
|
+
await loadSessionHistory(recentSessionIds[j].projectSlug, recentSessionIds[j].sessionId);
|
|
217
|
+
}
|
|
218
|
+
catch { }
|
|
219
|
+
}
|
|
220
|
+
if (recentSessionIds.length > 0) {
|
|
221
|
+
log.server("Data warmup: pre-cached history for %d recent sessions (%dms)", recentSessionIds.length, Date.now() - t0);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export function getWarmupModels() {
|
|
225
|
+
return warmupModels.length > 0 ? warmupModels : KNOWN_MODELS.slice();
|
|
226
|
+
}
|
|
227
|
+
export function getWarmupSlashCommands() {
|
|
228
|
+
return warmupSlashCommands;
|
|
229
|
+
}
|
|
230
|
+
export function getWarmupAccountInfo() {
|
|
231
|
+
return warmupAccountInfo;
|
|
232
|
+
}
|
|
233
|
+
export function getWarmupRateLimits() {
|
|
234
|
+
return Array.from(warmupRateLimits.values());
|
|
235
|
+
}
|
|
236
|
+
export function cacheRateLimitEntry(entry) {
|
|
237
|
+
var key = entry.rateLimitType || "default";
|
|
238
|
+
warmupRateLimits.set(key, entry);
|
|
239
|
+
}
|
|
240
|
+
export function isWarmupComplete() {
|
|
241
|
+
return warmupComplete;
|
|
242
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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.js";
|
|
5
|
+
import { log } from "./logger.js";
|
|
6
|
+
var vapidKeys = null;
|
|
7
|
+
var subscriptions = new Map();
|
|
8
|
+
function getVapidPath() {
|
|
9
|
+
return join(getLatticeHome(), "vapid.json");
|
|
10
|
+
}
|
|
11
|
+
function getSubscriptionsPath() {
|
|
12
|
+
return join(getLatticeHome(), "push-subs.json");
|
|
13
|
+
}
|
|
14
|
+
function ensureVapidKeys() {
|
|
15
|
+
if (vapidKeys)
|
|
16
|
+
return vapidKeys;
|
|
17
|
+
var vapidPath = getVapidPath();
|
|
18
|
+
if (existsSync(vapidPath)) {
|
|
19
|
+
try {
|
|
20
|
+
vapidKeys = JSON.parse(readFileSync(vapidPath, "utf-8"));
|
|
21
|
+
if (vapidKeys)
|
|
22
|
+
return vapidKeys;
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
}
|
|
26
|
+
var generated = webpush.generateVAPIDKeys();
|
|
27
|
+
vapidKeys = {
|
|
28
|
+
publicKey: generated.publicKey,
|
|
29
|
+
privateKey: generated.privateKey,
|
|
30
|
+
};
|
|
31
|
+
var dir = getLatticeHome();
|
|
32
|
+
if (!existsSync(dir)) {
|
|
33
|
+
mkdirSync(dir, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
writeFileSync(vapidPath, JSON.stringify(vapidKeys, null, 2), "utf-8");
|
|
36
|
+
log.server("Generated VAPID keys for push notifications");
|
|
37
|
+
return vapidKeys;
|
|
38
|
+
}
|
|
39
|
+
function loadSubscriptions() {
|
|
40
|
+
var subsPath = getSubscriptionsPath();
|
|
41
|
+
if (!existsSync(subsPath))
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
var data = JSON.parse(readFileSync(subsPath, "utf-8"));
|
|
45
|
+
for (var i = 0; i < data.length; i++) {
|
|
46
|
+
subscriptions.set(data[i].endpoint, data[i]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
}
|
|
51
|
+
function saveSubscriptions() {
|
|
52
|
+
var arr = [];
|
|
53
|
+
subscriptions.forEach(function (sub) {
|
|
54
|
+
arr.push(sub);
|
|
55
|
+
});
|
|
56
|
+
writeFileSync(getSubscriptionsPath(), JSON.stringify(arr), "utf-8");
|
|
57
|
+
}
|
|
58
|
+
export function initPush() {
|
|
59
|
+
var keys = ensureVapidKeys();
|
|
60
|
+
webpush.setVapidDetails("mailto:lattice@localhost", keys.publicKey, keys.privateKey);
|
|
61
|
+
loadSubscriptions();
|
|
62
|
+
log.server("Push notifications ready (%d subscription(s))", subscriptions.size);
|
|
63
|
+
}
|
|
64
|
+
export function getVapidPublicKey() {
|
|
65
|
+
return ensureVapidKeys().publicKey;
|
|
66
|
+
}
|
|
67
|
+
export function addPushSubscription(sub) {
|
|
68
|
+
subscriptions.set(sub.endpoint, sub);
|
|
69
|
+
saveSubscriptions();
|
|
70
|
+
}
|
|
71
|
+
export function removePushSubscription(endpoint) {
|
|
72
|
+
subscriptions.delete(endpoint);
|
|
73
|
+
saveSubscriptions();
|
|
74
|
+
}
|
|
75
|
+
export function sendPush(payload) {
|
|
76
|
+
if (subscriptions.size === 0)
|
|
77
|
+
return;
|
|
78
|
+
var json = JSON.stringify(payload);
|
|
79
|
+
subscriptions.forEach(function (sub, endpoint) {
|
|
80
|
+
webpush.sendNotification(sub, json).catch(function (err) {
|
|
81
|
+
if (err.statusCode === 410 || err.statusCode === 404 || err.statusCode === 403) {
|
|
82
|
+
subscriptions.delete(endpoint);
|
|
83
|
+
saveSubscriptions();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.js";
|
|
5
|
+
export function getCertsDir() {
|
|
6
|
+
var certsDir = join(getLatticeHome(), "certs");
|
|
7
|
+
if (!existsSync(certsDir)) {
|
|
8
|
+
mkdirSync(certsDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
return certsDir;
|
|
11
|
+
}
|
|
12
|
+
function isCertExpiringSoon(certPath) {
|
|
13
|
+
try {
|
|
14
|
+
var result = spawnSync("openssl", ["x509", "-enddate", "-noout", "-in", certPath], { encoding: "utf-8" });
|
|
15
|
+
if (result.status !== 0)
|
|
16
|
+
return true;
|
|
17
|
+
var match = result.stdout.match(/notAfter=(.+)/);
|
|
18
|
+
if (!match)
|
|
19
|
+
return true;
|
|
20
|
+
var expiryDate = new Date(match[1]);
|
|
21
|
+
var daysLeft = (expiryDate.getTime() - Date.now()) / (1000 * 60 * 60 * 24);
|
|
22
|
+
return daysLeft < 30;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function ensureCerts() {
|
|
29
|
+
var certsDir = getCertsDir();
|
|
30
|
+
var certPath = join(certsDir, "cert.pem");
|
|
31
|
+
var keyPath = join(certsDir, "key.pem");
|
|
32
|
+
if (existsSync(certPath) && existsSync(keyPath) && !isCertExpiringSoon(certPath)) {
|
|
33
|
+
return { cert: certPath, key: keyPath };
|
|
34
|
+
}
|
|
35
|
+
console.log("[lattice] Generating self-signed TLS certificate...");
|
|
36
|
+
var result = spawnSync("openssl", [
|
|
37
|
+
"req", "-x509",
|
|
38
|
+
"-newkey", "rsa:2048",
|
|
39
|
+
"-keyout", keyPath,
|
|
40
|
+
"-out", certPath,
|
|
41
|
+
"-days", "365",
|
|
42
|
+
"-nodes",
|
|
43
|
+
"-subj", "/CN=lattice",
|
|
44
|
+
], { encoding: "utf-8" });
|
|
45
|
+
if (result.status !== 0) {
|
|
46
|
+
throw new Error("[lattice] Failed to generate TLS certificates: " + (result.stderr || result.error?.message || "unknown error"));
|
|
47
|
+
}
|
|
48
|
+
console.log("[lattice] TLS certificates generated at " + certsDir);
|
|
49
|
+
return { cert: certPath, key: keyPath };
|
|
50
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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.js";
|
|
5
|
+
import { DEFAULT_PORT } from "#shared";
|
|
6
|
+
var BANNER = `
|
|
7
|
+
\x1b[36m██╗\x1b[0m \x1b[36m█████╗\x1b[0m \x1b[36m████████╗████████╗██╗\x1b[0m \x1b[36m██████╗\x1b[0m \x1b[36m███████╗\x1b[0m
|
|
8
|
+
\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
|
|
9
|
+
\x1b[36m██║\x1b[0m \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[36m██║\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[2m╚\x1b[0m\x1b[36m██████╗███████╗\x1b[0m
|
|
12
|
+
\x1b[2m╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝\x1b[0m
|
|
13
|
+
`;
|
|
14
|
+
export function printBanner() {
|
|
15
|
+
console.log(BANNER);
|
|
16
|
+
}
|
|
17
|
+
export function printStatus(config, version, projectCount, sessionCount) {
|
|
18
|
+
var protocol = config.tls ? "https" : "http";
|
|
19
|
+
var url = protocol + "://localhost:" + config.port;
|
|
20
|
+
console.log("");
|
|
21
|
+
p.note("lattice v" + version + " — " + url + "\n" +
|
|
22
|
+
projectCount + " project" + (projectCount !== 1 ? "s" : "") +
|
|
23
|
+
" · " + sessionCount + " session" + (sessionCount !== 1 ? "s" : "") + "\n" +
|
|
24
|
+
"Press Ctrl+C to stop", "Running");
|
|
25
|
+
console.log("");
|
|
26
|
+
}
|
|
27
|
+
export async function printQrCode(url) {
|
|
28
|
+
try {
|
|
29
|
+
var qrcode = await import("qrcode");
|
|
30
|
+
var qr = await qrcode.toString(url, {
|
|
31
|
+
type: "terminal",
|
|
32
|
+
small: true,
|
|
33
|
+
});
|
|
34
|
+
console.log(qr);
|
|
35
|
+
console.log(" \x1b[2m" + url + "\x1b[0m");
|
|
36
|
+
console.log("");
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
console.log(" " + url);
|
|
40
|
+
console.log("");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function runOnboarding() {
|
|
44
|
+
var configPath = join(getLatticeHome(), "config.json");
|
|
45
|
+
var isFirstRun = !existsSync(configPath);
|
|
46
|
+
if (!isFirstRun) {
|
|
47
|
+
var config = loadConfig();
|
|
48
|
+
return { port: config.port, passphrase: null };
|
|
49
|
+
}
|
|
50
|
+
printBanner();
|
|
51
|
+
p.intro("Welcome to Lattice");
|
|
52
|
+
p.note("Anyone with the URL gets full Claude Code access to this machine.\n" +
|
|
53
|
+
"Use a private network (Tailscale, VPN) or set a passphrase.", "Security");
|
|
54
|
+
var portResult = await p.text({
|
|
55
|
+
message: "Port",
|
|
56
|
+
placeholder: String(DEFAULT_PORT),
|
|
57
|
+
defaultValue: String(DEFAULT_PORT),
|
|
58
|
+
validate: function (val) {
|
|
59
|
+
var n = parseInt(val || "", 10);
|
|
60
|
+
if (isNaN(n) || n < 1 || n > 65535)
|
|
61
|
+
return "Enter a valid port (1-65535)";
|
|
62
|
+
return undefined;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
if (p.isCancel(portResult)) {
|
|
66
|
+
p.cancel("Setup cancelled");
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
var port = parseInt(portResult, 10);
|
|
70
|
+
var passphraseResult = await p.password({
|
|
71
|
+
message: "Passphrase (optional, press Enter to skip)",
|
|
72
|
+
});
|
|
73
|
+
if (p.isCancel(passphraseResult)) {
|
|
74
|
+
p.cancel("Setup cancelled");
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
var passphrase = passphraseResult || null;
|
|
78
|
+
p.outro("Setup complete");
|
|
79
|
+
var config = loadConfig();
|
|
80
|
+
config.port = port;
|
|
81
|
+
saveConfig(config);
|
|
82
|
+
return { port, passphrase };
|
|
83
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { log } from "./logger.js";
|
|
5
|
+
var __dirname_local = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
var PKG_NAME = "@cryptiklemur/lattice";
|
|
7
|
+
var GITHUB_REPO = "cryptiklemur/lattice";
|
|
8
|
+
var CHECK_INTERVAL_MS = 3600000;
|
|
9
|
+
var cached = null;
|
|
10
|
+
var checking = false;
|
|
11
|
+
function getCurrentVersion() {
|
|
12
|
+
if (process.env.LATTICE_VERSION)
|
|
13
|
+
return process.env.LATTICE_VERSION;
|
|
14
|
+
try {
|
|
15
|
+
var pkg = JSON.parse(readFileSync(join(__dirname_local, "../../package.json"), "utf-8"));
|
|
16
|
+
return pkg.version || "0.0.0";
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return "0.0.0";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function compareVersions(a, b) {
|
|
23
|
+
if (!a || !b || typeof a !== "string" || typeof b !== "string")
|
|
24
|
+
return 0;
|
|
25
|
+
var pa = a.replace(/^v/, "").split(".").map(Number);
|
|
26
|
+
var pb = b.replace(/^v/, "").split(".").map(Number);
|
|
27
|
+
for (var i = 0; i < 3; i++) {
|
|
28
|
+
var va = pa[i] || 0;
|
|
29
|
+
var vb = pb[i] || 0;
|
|
30
|
+
if (va !== vb)
|
|
31
|
+
return va - vb;
|
|
32
|
+
}
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
export function getInstallMode() {
|
|
36
|
+
return "npm";
|
|
37
|
+
}
|
|
38
|
+
async function checkGitHub(currentVersion) {
|
|
39
|
+
var res = await fetch("https://api.github.com/repos/" + GITHUB_REPO + "/releases/latest", {
|
|
40
|
+
headers: { "Accept": "application/vnd.github.v3+json" },
|
|
41
|
+
signal: AbortSignal.timeout(10000),
|
|
42
|
+
});
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
console.error("[lattice] GitHub update check failed: HTTP " + res.status);
|
|
45
|
+
return { currentVersion, latestVersion: null, updateAvailable: false, lastCheckedAt: Date.now(), releaseUrl: null, installMode: "binary" };
|
|
46
|
+
}
|
|
47
|
+
var data = await res.json();
|
|
48
|
+
var latestVersion = data.tag_name ? data.tag_name.replace(/^v/, "") : null;
|
|
49
|
+
var updateAvailable = latestVersion !== null && compareVersions(latestVersion, currentVersion) > 0;
|
|
50
|
+
return {
|
|
51
|
+
currentVersion,
|
|
52
|
+
latestVersion,
|
|
53
|
+
updateAvailable,
|
|
54
|
+
lastCheckedAt: Date.now(),
|
|
55
|
+
releaseUrl: updateAvailable ? (data.html_url ?? null) : null,
|
|
56
|
+
installMode: "binary",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function checkNpm(currentVersion) {
|
|
60
|
+
var res = await fetch("https://registry.npmjs.org/" + PKG_NAME + "/latest", {
|
|
61
|
+
headers: { "Accept": "application/json" },
|
|
62
|
+
signal: AbortSignal.timeout(10000),
|
|
63
|
+
});
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
console.error("[lattice] npm update check failed: HTTP " + res.status);
|
|
66
|
+
return { currentVersion, latestVersion: null, updateAvailable: false, lastCheckedAt: Date.now(), releaseUrl: null, installMode: "npm" };
|
|
67
|
+
}
|
|
68
|
+
var data = await res.json();
|
|
69
|
+
var latestVersion = data.version ?? null;
|
|
70
|
+
var updateAvailable = latestVersion !== null && compareVersions(latestVersion, currentVersion) > 0;
|
|
71
|
+
return {
|
|
72
|
+
currentVersion,
|
|
73
|
+
latestVersion,
|
|
74
|
+
updateAvailable,
|
|
75
|
+
lastCheckedAt: Date.now(),
|
|
76
|
+
releaseUrl: updateAvailable ? "https://github.com/" + GITHUB_REPO + "/releases/tag/v" + latestVersion : null,
|
|
77
|
+
installMode: "npm",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export async function checkForUpdate(force = false) {
|
|
81
|
+
var currentVersion = getCurrentVersion();
|
|
82
|
+
if (!force && cached && Date.now() - cached.lastCheckedAt < CHECK_INTERVAL_MS) {
|
|
83
|
+
return cached;
|
|
84
|
+
}
|
|
85
|
+
if (checking) {
|
|
86
|
+
return cached ?? { currentVersion, latestVersion: null, updateAvailable: false, lastCheckedAt: 0, releaseUrl: null, installMode: getInstallMode() };
|
|
87
|
+
}
|
|
88
|
+
checking = true;
|
|
89
|
+
try {
|
|
90
|
+
cached = await checkNpm(currentVersion);
|
|
91
|
+
if (cached.updateAvailable) {
|
|
92
|
+
log.server("Update available: %s -> %s (%s)", currentVersion, cached.latestVersion, cached.installMode);
|
|
93
|
+
}
|
|
94
|
+
return cached;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
console.error("[lattice] Update check error: " + (err instanceof Error ? err.message : String(err)));
|
|
98
|
+
cached = { currentVersion, latestVersion: null, updateAvailable: false, lastCheckedAt: Date.now(), releaseUrl: null, installMode: getInstallMode() };
|
|
99
|
+
return cached;
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
checking = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export function getCachedUpdateInfo() {
|
|
106
|
+
return cached;
|
|
107
|
+
}
|
|
108
|
+
export function getPackageName() {
|
|
109
|
+
return PKG_NAME;
|
|
110
|
+
}
|
|
111
|
+
export function getGitHubRepo() {
|
|
112
|
+
return GITHUB_REPO;
|
|
113
|
+
}
|
|
114
|
+
export function startPeriodicUpdateCheck() {
|
|
115
|
+
void checkForUpdate();
|
|
116
|
+
setInterval(function () {
|
|
117
|
+
void checkForUpdate();
|
|
118
|
+
}, CHECK_INTERVAL_MS);
|
|
119
|
+
}
|