@www.hyperlinks.space/program-kit 1.2.3 → 1.2.181818

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +8 -8
  2. package/app/_layout.tsx +5 -6
  3. package/app/index.tsx +1 -1
  4. package/assets/images/PreviewImage.png +0 -0
  5. package/database/start.ts +1 -3
  6. package/docs/build_and_install.md +6 -6
  7. package/docs/npm-release.md +46 -0
  8. package/docs/releases.md +5 -5
  9. package/docs/releases_github_actions.md +5 -5
  10. package/docs/security_plan_raw.md +4 -4
  11. package/docs/security_raw.md +2 -2
  12. package/docs/timing_raw.md +7 -7
  13. package/docs/update.md +11 -11
  14. package/docs/wallet_telegram_standalone_multichain_proposal.md +192 -0
  15. package/docs/wallets_hosting_architecture.md +1 -1
  16. package/fullREADME.md +101 -81
  17. package/npmReadMe.md +8 -8
  18. package/package.json +2 -2
  19. package/scripts/load-env.ts +1 -3
  20. package/scripts/test-api-base.ts +1 -1
  21. package/tsconfig.json +1 -1
  22. package/windows/build.cjs +1 -1
  23. package/windows/cleanup-legacy-appdata-installs.ps1 +1 -1
  24. package/windows/product-brand.cjs +1 -1
  25. package/app/components/GlobalBottomBar.tsx +0 -447
  26. package/app/components/GlobalBottomBarWeb.tsx +0 -362
  27. package/app/components/GlobalLogoBar.tsx +0 -108
  28. package/app/components/GlobalLogoBarFallback.tsx +0 -66
  29. package/app/components/GlobalLogoBarWithFallback.tsx +0 -24
  30. package/app/components/HyperlinksSpaceLogo.tsx +0 -29
  31. package/app/components/Telegram.tsx +0 -648
  32. package/app/components/telegramWebApp.ts +0 -359
  33. package/app/fonts.ts +0 -12
  34. package/app/theme.ts +0 -117
  35. package/docs/backlogs/medium_term_backlog.md +0 -26
  36. package/docs/backlogs/short_term_backlog.md +0 -39
  37. package/eslint.config.js +0 -10
@@ -0,0 +1,192 @@
1
+ # Unified Wallet Model: Telegram, Standalone, Multi-Chain & DLLR (TON)
2
+
3
+ This document proposes a single coherent setup for the tensions between:
4
+
5
+ - A **Telegram-first** experience (Mini App, bot confirmations, CloudStorage-assisted UX).
6
+ - **Standalone operation** when Telegram is unavailable, blocked, or the user simply prefers not to use it.
7
+ - **Non-custodial** custody: keys and mnemonics never held by our servers.
8
+ - **DLLR** and core product flows anchored on **TON**, where issuance and program logic are expected to live.
9
+ - **Multiple chains** where users may hold assets or use bridges, without fragmenting identity or safety.
10
+
11
+ It complements `wallets_hosting_architecture.md`, `security_raw.md`, and `security_plan_raw.md` by resolving “which path wins when” and how they fit together.
12
+
13
+ ---
14
+
15
+ ## 1. Core idea: one logical wallet, three *surfaces*
16
+
17
+ Think in terms of **one user-owned root of trust** (mnemonic for the primary TON wallet, and optional additional key material for other chains), and **three ways to use it**:
18
+
19
+ | Surface | What it is | Best for |
20
+ |--------|------------|----------|
21
+ | **A. Telegram-hosted (TMA)** | Same non-custodial keys; encrypted material split between Telegram `SecureStorage` + `CloudStorage` (ciphertext only), identity via `initData`. | Smoothest UX inside Telegram, bot-driven tx confirmation, push-to-sign. |
22
+ | **B. Unhosted / standalone** | Keys only on device OS keystore / WebCrypto; no Telegram APIs required to open the app or sign. | Telegram outage, privacy preference, store-review-friendly “works without Telegram”. |
23
+ | **C. Connected** | External wallets via **TON Connect** (TON) and, later, analogous **WalletConnect** / chain-specific SDKs for other networks. | Power users, hardware wallets, assets already elsewhere. |
24
+
25
+ **Important:** Surfaces are **not** different custodial models. They differ only in **where keys live** and **which transport** is used for identity and sync. The backend stores **public** data (addresses, `telegram_username` ↔ address mapping when the user opts in), never mnemonics.
26
+
27
+ ---
28
+
29
+ ## 2. Why Telegram alone is not enough (and how we fix it)
30
+
31
+ Telegram can be unreachable (outage, censorship, user choice). A product that *only* creates or signs inside the Mini App forces a hard dependency on Telegram for custody and signing.
32
+
33
+ **Proposal:**
34
+
35
+ 1. **Default recommended path** remains: create primary **TON** wallet in TMA (best onboarding, aligns with bot + DLLR messaging).
36
+ 2. **Mandatory parallel capability:** the same app build supports **Create / Restore wallet locally** (standalone) with **no Telegram account** and **no bot call** for key generation.
37
+ 3. **Linking layer (optional):** if the user *has* Telegram, they can **link** `telegram_username` ↔ `wallet_address` so CloudStorage sync and bot confirmations work. If they never link, they remain fully standalone; DLLR/Ton features still work on-chain by address.
38
+ 4. **Degraded mode:** if Telegram is down but the user already has keys on device, the app runs **full local signing** for TON (and any chain we have implemented client-side). Features that *require* the bot (e.g. push approval via Telegram) show a clear “Unavailable while Telegram is unreachable” with fallback: open pending items in TMA later, or confirm via standalone signing if the flow allows.
39
+
40
+ This matches non-custodial rules: the server never becomes the signing authority.
41
+
42
+ ---
43
+
44
+ ## 3. DLLR on TON as the canonical product wallet
45
+
46
+ **Clarification to remove confusion:**
47
+
48
+ - **Primary app wallet** = **TON** address derived from the user’s main mnemonic (or from a TON Connect wallet they set as default).
49
+ - **DLLR** is treated as a **TON jetton / program** (or locked-state construct per your issuance design). Balances, locks, and allocations are **read and signed on TON**.
50
+ - “Multi-chain” does **not** mean DLLR exists on every chain. It means:
51
+ - **User may connect other addresses** for portfolio view, bridges, or future features.
52
+ - **Product-critical flows** (rewards, locks, compliance hooks tied to DLLR) stay **TON-first**.
53
+
54
+ **UI rule:** always show a clear **“Primary (TON + DLLR)”** section, then **“Other networks”** as secondary, so expectations stay aligned with issuance on TON.
55
+
56
+ ---
57
+
58
+ ## 4. Multi-chain matrix (recommended model)
59
+
60
+ Use a single **wallet registry** in the client and the `wallets` table (as in `security_plan_raw.md`), with explicit `blockchain`, `net`, and `type`:
61
+
62
+ | Type | Example | Custody |
63
+ |------|---------|--------|
64
+ | `internal` | App-generated TON keypair | Non-custodial; keys in device/TMA storage |
65
+ | `tonconnect` | Tonkeeper, MyTonWallet | User’s external wallet; we only hold address + session |
66
+ | `walletconnect` / `evm` / `solana` (future) | MetaMask, Phantom, … | Same: address + connection state |
67
+
68
+ **Telegram-hosted vs unhosted** applies only to **`internal`** wallets:
69
+
70
+ - In TMA, `internal` wallet uses SecureStorage + CloudStorage ciphertext split.
71
+ - In standalone app, `internal` wallet uses only OS secure storage (same cryptography, different storage adapters).
72
+
73
+ **Connected** wallets are **always** “hosted” by the third-party provider, not by Telegram and not by us.
74
+
75
+ ---
76
+
77
+ ## 5. Identity: Telegram as optional glue, not a single gate
78
+
79
+ Today’s docs lean **Telegram-first** for onboarding. The unified model adds:
80
+
81
+ | User state | Can use app? | DLLR / TON actions |
82
+ |------------|--------------|--------------------|
83
+ | Standalone, never linked Telegram | Yes (after local create/restore) | Yes, if keys on device |
84
+ | Telegram user, wallet only in TMA | Yes in TMA; on mobile/web after Telegram Login | Signing in TMA; read-only elsewhere unless mnemonic imported locally (optional advanced) |
85
+ | Linked Telegram + local keys | Yes everywhere | Full: bot confirmations where implemented + local signing fallback |
86
+
87
+ **Backend:**
88
+
89
+ - `users.telegram_username` is **nullable** for standalone-only users, or use a separate **account id** (emailless) keyed by device-chosen identifier only for analytics—not for custody.
90
+ - Linking Telegram is a **deliberate** step: “Connect Telegram for notifications and faster sync.”
91
+
92
+ ---
93
+
94
+ ## 6. First run and subsequent runs (program behavior)
95
+
96
+ This section describes what the **client program** does on **cold start** (first launch or fresh install) versus **later launches** on the same install, for each major surface. It aligns with the state machine in `wallets_hosting_architecture.md` (e.g. `awallet_v1`, deploy status).
97
+
98
+ ### 6.1 Shared startup sequence (all surfaces)
99
+
100
+ 1. **Bootstrap UI shell** — Router loads; global providers start (network, wallet context).
101
+ 2. **Detect environment** — `TMA` (Telegram WebApp present) vs **standalone** (Expo native / open web) vs **web + Telegram Login** (widget session).
102
+ 3. **Resolve wallet presence** — Read local secure storage keys (`awallet_v1` or equivalent): encrypted blob for `internal` wallet, plus any **connected** wallet session handles (TON Connect).
103
+ 4. **Branch:**
104
+ - **No wallet record** → onboarding (Section 6.2).
105
+ - **Wallet record present** → main app (Section 6.3).
106
+
107
+ Balances and DLLR/TON state are **always** refreshed asynchronously after UI is usable (do not block first paint on RPC unless product requires it).
108
+
109
+ ---
110
+
111
+ ### 6.2 First run (no wallet on this install)
112
+
113
+ | Entry | What the user sees | What the program does |
114
+ |--------|--------------------|------------------------|
115
+ | **Telegram Mini App** | Intro → **Create wallet** / **Restore wallet** (optional **Connect Tonkeeper** if offered). | Generates mnemonic locally; stores **wallet master key** in Telegram `SecureStorage`; stores **seed ciphertext** in `CloudStorage`; registers **public** `wallet_address` (+ `telegram_username` from `initData`) with backend. Shows address and QR immediately; may show **Deploying** for SMC/jetton setup; nudges **backup seed**. |
116
+ | **Standalone (native / web, no Telegram)** | Same choice: **Create** / **Restore** / **Connect** external wallet. | Generates or imports keys using **only** OS keystore / WebCrypto; **no** `initData`, **no** CloudStorage unless user later links Telegram. Optional backend call with a **non-Telegram** account id or anonymous mode until linked. |
117
+ | **Store mobile app (Telegram-centric onboarding)** | Per `security_raw.md`: “Create wallet in Telegram” vs “I already have a wallet” + **Log in with Telegram**. | First path deep-links to TMA; second uses **Telegram Login** to fetch **public** linkage (`username` → `wallet_address`) for **read-only** until user imports mnemonic on device (if you add that flow). |
118
+
119
+ **First run, new Telegram device (TMA):** `CloudStorage` may already hold **ciphertext** from another device, but **SecureStorage** is empty → program shows **Authorize this device** and asks for **mnemonic once**, then writes local master key and proceeds as normal.
120
+
121
+ **First run, connected wallet only (TON Connect):** No internal blob; program stores connection session + address; primary balance flows use that address until user adds an `internal` wallet.
122
+
123
+ ---
124
+
125
+ ### 6.3 Subsequent runs (wallet already on this device)
126
+
127
+ | Condition | Program behavior |
128
+ |-----------|------------------|
129
+ | **Encrypted blob + device key present** | **Silent load:** decrypt wallet, navigate to **home / wallet** without asking for seed. Poll `/wallet/status` or chain APIs for **deploy status**, **TON balance**, **DLLR** state. If deploy was **pending**, **retry deploy** in background (same as `wallets_hosting_architecture.md`). |
130
+ | **TMA + CloudStorage ciphertext + SecureStorage OK** | Same silent path; CloudStorage may sync updates from other Telegram clients. |
131
+ | **Standalone + keys in local secure storage** | Same as row 1; **no** Telegram dependency for open or sign. |
132
+ | **User opened “Log in with Telegram” on mobile** | After verified login, app loads **cached** `telegram_username` + **addresses** from API; UI is **read-first** until local signing is enabled (mnemonic import), matching your phased plan. |
133
+ | **Telegram unavailable (outage / blocked)** | If keys exist locally: **full app** for signing and reads that do not need the bot. If keys exist **only** in TMA on a device that cannot open Telegram: user must use **restore** on standalone build or wait for Telegram. Features that need the bot show **degraded / queue** messaging. |
134
+ | **App update** | Same storage keys (`awallet_v1` versioning); run **migration** if blob format bumps. Wallet survives update if paths are stable. |
135
+
136
+ **Subsequent run UX expectations:** back up seed remains **dismissible** until acknowledged; high-value actions may still route through **pending tx + bot confirmation** when Telegram is linked and the flow requires it.
137
+
138
+ ---
139
+
140
+ ### 6.4 Summary table
141
+
142
+ | | First run | Subsequent runs |
143
+ |---|-----------|-----------------|
144
+ | **Typical path** | Onboarding → create / restore / connect | Silent unlock → home → background balance/deploy sync |
145
+ | **Telegram required?** | Only for TMA path or Telegram-login shell | No, if standalone keys exist; yes for TMA-specific features |
146
+ | **Seed prompt** | At creation (show once) or restore; optional “authorize device” on new TMA device | Only if blob missing, storage wiped, or user hits **Restore** |
147
+
148
+ ---
149
+
150
+ ## 7. “Perfect setup” summary (one paragraph)
151
+
152
+ **Ship one Expo app** with three entry modes: (1) **Telegram Mini App** for best-in-class onboarding, CloudStorage-backed ciphertext sync, and bot-mediated confirmations; (2) **standalone** create/restore so the app **always launches** and can sign TON (and DLLR) without Telegram; (3) **TON Connect + future multi-chain connectors** for imported liquidity and power users. Treat **TON + DLLR** as the single source of truth for product economics; treat other chains as **attached accounts**. Keep **mnemonic / keys** only on the client, **ciphertext** in CloudStorage when Telegram is used, and **public addresses + optional Telegram link** on the server. When Telegram is down, **degrade gracefully**: local signing and read paths keep working; Telegram-only steps queue or hide with clear messaging.
153
+
154
+ ---
155
+
156
+ ## 8. Implementation phases (aligned with existing roadmap)
157
+
158
+ 1. **Phase A — Standalone parity (minimum viable resilience)**
159
+ - Unhosted TON create/restore in **Expo web + native** without Telegram.
160
+ - Same `WalletService` abstraction as in `wallets_hosting_architecture.md`; storage backend switches on environment (TMA vs native).
161
+ - Optional “Link Telegram” after the fact.
162
+
163
+ 2. **Phase B — Linking & DB**
164
+ - Nullable Telegram on `users`; `wallets` rows for `internal` + `tonconnect`.
165
+ - Telegram Login only for users who want cross-surface sync.
166
+
167
+ 3. **Phase C — Bot confirmations + queue**
168
+ - Pending tx from any client; confirmation in TMA when available; standalone users complete via **local sign** without bot where the protocol allows.
169
+
170
+ 4. **Phase D — Multi-chain read + selective write**
171
+ - Add connected chains for **display** first; add signing per chain as product requires.
172
+
173
+ ---
174
+
175
+ ## 9. Security notes (unchanged principles)
176
+
177
+ - No mnemonic on server; CloudStorage holds **ciphertext only**; device-bound keys decrypt.
178
+ - Telegram Login proves **identity**, not possession of keys.
179
+ - Standalone users rely on **seed backup** exactly as in self-custody best practice.
180
+ - DLLR issuance rules remain **on-chain** on TON; our app is a **client**, not an issuer.
181
+
182
+ ---
183
+
184
+ ## 10. Open decisions (to refine with product/legal)
185
+
186
+ - Whether standalone users get **full** DLLR program participation or **subset** until KYC/Telegram link (if required by issuance policy).
187
+ - Exact **jetton master** and **wallet v4/v5** choices for DLLR display and deploy flows.
188
+ - Whether **one mnemonic** derives only TON or also other chains (prefer **separate mnemonics** per chain unless using a documented multi-chain HD profile).
189
+
190
+ ---
191
+
192
+ *Proposal doc; iterate with team and adjust table/column names to match the actual migration from `security_plan_raw.md`.*
@@ -254,4 +254,4 @@ Swap between implementations via a flag (`kUseMockWalletState` for dev, env-driv
254
254
 
255
255
  ---
256
256
 
257
- *Last updated: April 2026. Maintained in repo at `app/docs/wallet_architecture.md`.*
257
+ *Last updated: April 2026. Maintained in repo at `docs/wallets_hosting_architecture.md`.*
package/fullREADME.md CHANGED
@@ -1,68 +1,100 @@
1
- # Welcome to your Expo app 👋
2
- This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
1
+ ![Preview Image](https://raw.githubusercontent.com/HyperlinksSpace/HyperlinksSpaceProgram/refs/heads/main/assets/images/PreviewImage.png)
3
2
 
4
- ## Get started
3
+ # Hyperlinks Space Program
5
4
 
6
- To start the app (and the Telegram bot in polling mode), run:
5
+ <u>**In progress, contribute!**</u>
6
+
7
+ This program is built upon [React Native](https://reactnative.dev/) by Meta and [Expo](https://expo.dev) multiplatform technologies, Windows build and executable creation achieved with [Electron Builder](https://www.electron.build/) and [Electron Forge](https://www.electronforge.io/), working in Telegram with help of [Telegram Mini Apps React SDK](http://telegram-mini-apps.com/) and [Bot API](https://core.telegram.org/bots). AI is backed by [OpenAI API](https://openai.com/ru-RU/api/), blockchain data is processed from [Swap.Coffee API](https://docs.swap.coffee/eng/user-guides/welcome).
8
+
9
+ ## Program Kit
10
+
11
+ To give value for other developers we decided to launch an npm package that provides a ready starter for creating a multiplatform program in one command.
7
12
 
8
13
  ```bash
9
- npm run start
14
+ npx @www.hyperlinks.space/program-kit ./new-program
10
15
  ```
11
16
 
12
- This runs both the Expo dev server and the bot. For Expo only (no bot), use `npm run start:expo`.
17
+ Link to the package: https://www.npmjs.com/package/@www.hyperlinks.space/program-kit
13
18
 
14
- ## Milestone snapshot package (npm)
19
+ ## Program design
15
20
 
16
- This repository includes a publishable snapshot package for fast developer bootstrap:
21
+ Access [Figma](https://www.figma.com/design/53lDKAD6pRv3e0uef1DP18/TECHSYMBAL-Inc.?node-id=754-71&t=v3tmAlywNgXkTWMd-1) in real time for contributing. Contact [Seva](t.me/sevaaignatyev) in Telegram to discuss and implement.
17
22
 
18
- - package source: `app/` (published directly, no duplicate snapshot folder)
19
- - **npmjs (public):** `@www.hyperlinks.space/program-kit` — manage org and tokens: [www.hyperlinks.space on npm](https://www.npmjs.com/settings/www.hyperlinks.space/packages)
20
- - **GitHub Packages:** `@hyperlinksspace/program-kit` (same version; GitHub requires the package scope to match this repo’s owner)
23
+ Copying fully or partially, usage as an inspiration for other developments are unpleasant, participation in our projects is appreciated. All core materials are available publicly for instant access worldwide and our project availability for newcomers.
21
24
 
22
- **npm ownership:** your token must be allowed to publish under scope `@www.hyperlinks.space` (org members or automation token with access to that org).
25
+ ## How to fork and contribute?
23
26
 
24
- ### Verify publish payload locally
27
+ 1. Install GitHub CLI and authorize to GitHub from CLI for instant work
25
28
 
26
- The npm package page uses `README.md` from the published tarball, not `npmReadMe.md`. The published package also includes **`fullREADME.md`**, a copy of this developer readme (saved before the npm readme replaces `README.md`). Match CI before `npm pack`, then restore:
29
+ ```
30
+ winget install --id GitHub.cli
31
+ gh auth login
32
+ ```
27
33
 
28
- ```bash
29
- cp README.md fullREADME.md
30
- cp npmReadMe.md README.md
31
- npm pack --dry-run
32
- git checkout -- README.md
33
- rm -f fullREADME.md
34
+ 2. Fork the repo, clone it and create a new branch and switch to it
35
+
36
+ ```
37
+ gh repo fork https://github.com/HyperlinksSpace/HyperlinksSpaceBot.git --clone
38
+ git checkout -b new-branch-for-an-update
39
+ git switch -c new-branch-for-an-update
34
40
  ```
35
41
 
36
- ### Install snapshot as a developer
42
+ 3. Make a commit (address unassigned issue or think yourself)
37
43
 
38
- ```bash
39
- npx @www.hyperlinks.space/program-kit ./my-hsp-app
44
+ ```
45
+ git add . # Stage changes on this branch
46
+ git commit -m "Describe your change" # Commit on this branch
47
+ ```
48
+
49
+ 3. After making a commit, make a pull request, gh tool will already know the upstream remote
50
+
51
+ ```
52
+ gh pr create --title "My new PR" --body "It is my best PR"
53
+ ```
54
+
55
+ 4. For subsequent commits (sync `main`, create a fresh branch, and commit there)
56
+
57
+ ```
58
+ git checkout main # Return to main
59
+ git fetch upstream # Fully sync with upstream main
60
+ git reset --hard upstream/main # Reset local main to upstream/main
61
+ git push origin main # Keep your fork main in sync too
62
+ git switch -c new-branch-for-next-update # Create and switch to a new feature branch
40
63
  ```
41
64
 
42
- The CLI materializes the bundled package payload into your target folder, then you run:
65
+ **Move in loops starting from the step 3.**
66
+
67
+ ## Pull requests and commits requirements
68
+
69
+ - Give pull requests and commits a proper name and description
70
+ - Dedicate each pull request to an understandable area or field, each commit to a focused logical change
71
+ - Check file changes in every commit pulled, no arbitrary files modifications should persist such as LF/CRLF line-ending conversion, broken/garbled text diffs, BOM added or removed, accidental "invisible" corruption from text filters
72
+ - Add dependecies and packages step by step for security
73
+ - An issue creation or following an existing before a pull request would be a good practice
74
+
75
+ ## Local deploy
76
+
77
+ To start the full local stack, run:
43
78
 
44
79
  ```bash
45
- cd my-hsp-app
46
- npm install
80
+ npm run start
47
81
  ```
48
82
 
49
- ### Release channels
83
+ This runs Expo dev server, the Telegram bot (polling mode), and local Vercel API (`vercel dev`).
50
84
 
51
- - `latest`: immutable stable snapshots (tag workflow `snapshot-vX.Y.Z`)
52
- - `next`: rolling snapshots from manual workflow dispatch
85
+ Isolated/local run options:
53
86
 
54
- In the output, you'll find options to open the app in:
87
+ - Expo only (no bot, no Vercel): `npm run start:expo`
88
+ - Bot only (polling mode): `npm run bot:local`
89
+ - Vercel API only: `npm run dev:vercel`
55
90
 
56
- - [a development build](https://docs.expo.dev/develop/development-builds/introduction/)
57
- - [an Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
58
- - [an iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
59
- - [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
91
+ ## Milestone snapshot package (npm)
60
92
 
61
- You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
93
+ NPM release and snapshot details were moved to `docs/npm-release.md`.
62
94
 
63
95
  ### Local env setup
64
96
 
65
- 1. **Copy the example file** (from the `app/` directory):
97
+ 1. **Copy the example file** (from the repository root):
66
98
  ```bash
67
99
  cp .env.example .env
68
100
  ```
@@ -77,9 +109,22 @@ You can start developing by editing the files inside the **app** directory. This
77
109
 
78
110
  The `.env` file is gitignored; do not commit it.
79
111
 
80
- ## Workflows
112
+ ## GitHub Actions
113
+
114
+ Current Actions workflows include:
115
+
116
+ - `Vercel Deploy Test` (`.github/workflows/vercel-deploy-test-envs.yml`) - manual web deploy to Vercel.
117
+ - `NPM Package Release` (`.github/workflows/npm-package-release.yml`) - npm/GitHub Packages release workflow.
118
+ - `Electron EXE Release` and `Electron Forge EXE Release` - manual Windows release pipelines.
119
+ - `EXPO Publish` (`.github/workflows/expo-publish.yml`) - manual OTA publish with EAS CLI.
120
+ - `Lint errors check` (`.github/workflows/lint-errors-check.yml`) - manual lint check.
121
+
122
+ ## Expo Workflows
123
+
124
+ This project uses two automation layers:
81
125
 
82
- This project is configured to use [EAS Workflows](https://docs.expo.dev/eas/workflows/get-started/) to automate some development and release processes. These commands are set up in [`package.json`](./package.json) and can be run using NPM scripts in your terminal.
126
+ - [EAS Workflows](https://docs.expo.dev/eas/workflows/get-started/) for Expo update/build/deploy flows (triggered via npm scripts from [`package.json`](./package.json)).
127
+ - GitHub Actions for CI/CD tasks stored in `.github/workflows` (manual release/deploy jobs and checks).
83
128
 
84
129
  ### Previews
85
130
 
@@ -99,61 +144,36 @@ Expo offers hosting for websites and API functions via EAS Hosting. See the [Get
99
144
 
100
145
  ### Deploy web build to Vercel
101
146
 
102
- From this directory (`app/`), deploy the static web build to Vercel production:
147
+ From the repository root, deploy the static web build to Vercel production:
103
148
 
104
149
  ```bash
105
150
  vercel --prod
106
151
  ```
107
152
 
108
- Deploying from `app/` makes this folder the project root, so `api/bot` is deployed and no Root Directory setting is needed. The project is configured so Vercel runs `npx expo export -p web` and serves the `dist/` output. Link the project first with `vercel` if needed.
153
+ Deploying from repository root makes this folder the project root, so `api/bot` is deployed and no Root Directory setting is needed. The project is configured so Vercel runs `npx expo export -p web` and serves the `dist/` output. Link the project first with `vercel` if needed.
109
154
 
110
- ### Telegram bot (Grammy)
155
+ ## Telegram bot (Grammy)
111
156
 
112
- A minimal bot that replies "Hello" is included. It is deployable on Vercel via webhook and runnable locally with getUpdates.
157
+ The bot is extended beyond a basic "Hello" and "Start program" responder and now supports AI streaming and threads.
113
158
 
114
159
  **Vercel (webhook)**
115
- - **Env for deploy:** In Vercel **Settings → Environment Variables** add **`BOT_TOKEN`** (or `TELEGRAM_BOT_TOKEN`). Assign to **Production** (and to **Build** if your dashboard has that option) so the deploy-step webhook script can run. The webhook URL is built from Vercel’s `VERCEL_PROJECT_PRODUCTION_URL` or `VERCEL_URL`.
116
- - **Webhook on deploy:** Each build runs `scripts/set-webhook.ts` and calls Telegram `setWebhook` with the base URL + `/api/bot`. If the script fails (e.g. missing URL or Telegram error), the build fails so you see the error in the deploy log.
117
- - Telegram sends updates to **POST** `/api/bot`; the bot replies "Hello".
160
+ - **Runtime path:** Telegram sends updates to `POST /api/bot`. This route proxies to the shared bot webhook handler in `bot/webhook`.
161
+ - **Webhook setup:** `scripts/set-webhook.ts` sets `https://<base>/api/bot` using `VERCEL_PROJECT_PRODUCTION_URL` (preferred) or `VERCEL_URL`.
162
+ - **Required env:** set `BOT_TOKEN` (or `TELEGRAM_BOT_TOKEN`) in Vercel project envs for production deploys.
163
+ - **Deploy flow:** webhook mode is intended for Vercel deploys (CLI `vercel --prod` or the manual GitHub Action `Vercel Deploy (Test Envs)`).
118
164
 
119
165
  **Bot works locally but not on Vercel**
120
- 1. Open **GET** `https://<your-app>.vercel.app/api/bot` in a browser. The JSON shows:
121
- - `bot: true` BOT_TOKEN is set; `bot: false` add BOT_TOKEN in Vercel → Settings → Environment Variables (Production), then redeploy.
122
- - `expected_url` URL we use for the webhook (from VERCEL_PROJECT_PRODUCTION_URL or VERCEL_URL).
123
- - `telegram_has` → URL Telegram actually has. It must match your production URL (e.g. `https://hsbexpo.vercel.app/api/bot`). If it’s `(none)` or different, ensure the project’s production domain is set in Vercel and redeploy so set-webhook.ts runs with the correct URL.
124
- - `webhook_set: true` → last setWebhook call succeeded.
125
- 2. **Root directory:** Only needed if you deploy via Git (auto-deploy from the repo). Then set **Root Directory** to **`app`** in Vercel → Project Settings → General. If you always run `vercel --prod` from inside `app/`, the CLI uses this folder as the project root and you don’t need to set it.
126
- 3. **Logs:** After sending /start, check **Logs** for `[webhook] POST update` and any `[bot]` errors (e.g. handler_error, timeout).
127
- 4. Don’t run the same bot in polling locally while testing the webhook (or Telegram may deliver updates to the wrong place).
166
+ 1. Confirm Vercel env has `BOT_TOKEN` and redeploy.
167
+ 2. Ensure the deployed URL is stable and matches the webhook target (`/api/bot`).
168
+ 3. Check deploy/runtime logs for `[set-webhook]` and `[webhook]` errors.
169
+ 4. Do not run local polling with the same token while validating webhook mode.
128
170
 
129
171
  **Local (getUpdates, no webhook)**
130
- - Only `BOT_TOKEN` is required (in env or `.env`).
131
- - Run the bot in polling mode (do not use the same token with webhook set elsewhere):
132
- ```bash
133
- npx tsx scripts/run-bot-local.ts
134
- ```
135
- - `npm run start` runs both Expo and the bot; or run the bot alone with `npm run bot:local`.
136
-
137
- ## Get a fresh project
138
-
139
- When you're ready, run:
140
-
141
- ```bash
142
- npm run reset-project
143
- ```
144
-
145
- This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
146
-
147
- ## Learn more
148
-
149
- To learn more about developing your project with Expo, look at the following resources:
150
-
151
- - [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
152
- - [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
153
-
154
- ## Join the community
172
+ - Only `BOT_TOKEN` is required (env or `.env`).
173
+ - Run bot only: `npm run bot:local`
174
+ - Run full local stack (Expo + bot + Vercel): `npm run start`
175
+ - Keep production and local bot tokens separate when possible to avoid webhook/polling conflicts.
155
176
 
156
- Join our community of developers creating universal apps.
177
+ ## Where to discuss the project?
157
178
 
158
- - [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
159
- - [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
179
+ This repository has [GitHub Discussions](https://github.com/HyperlinksSpace/HyperlinksSpaceProgram/discussions) opened, as well you can join our [Telegram Chat](https://t.me/HyperlinksSpaceChat) and [Channel](https://t.me/HyperlinksSpace).
package/npmReadMe.md CHANGED
@@ -1,30 +1,31 @@
1
1
  # Program Kit
2
2
 
3
- Program Kit is a production-ready cross-platform starter published from `app/`.
3
+ Program Kit is a production-ready cross-platform starter published from repository root.
4
4
  It is built around React Native + Expo and is designed to be quickly tested, scaled,
5
5
  and deployed across popular platforms.
6
6
 
7
7
  ## What You Get
8
8
 
9
9
  - Expo + React Native app foundation
10
- - Telegram bot support (webhook + local bot scripts)
10
+ - Telegram bot support (webhook + local bot scripts) with AI functionality
11
11
  - Telegram Mini App-ready client structure
12
- - Android and iOS workflow scripts
12
+ - Android and iOS clients
13
13
  - Windows desktop packaging (`.exe`) with Electron Builder
14
14
  - CI-oriented release workflow and deployment helpers
15
+ - OpenAI functionality and Swap.Coffee for blockchain data retrievement
15
16
 
16
17
  ## Install
17
18
 
18
19
  ### npmjs (public)
19
20
 
20
21
  ```bash
21
- npx @www.hyperlinks.space/program-kit ./my-new-program
22
+ npx @www.hyperlinks.space/program-kit ./new-program
22
23
  ```
23
24
 
24
25
  ### GitHub Packages
25
26
 
26
27
  ```bash
27
- npx @hyperlinksspace/program-kit ./my-new-program
28
+ npx @hyperlinksspace/program-kit ./new-program
28
29
  ```
29
30
 
30
31
  If you install from GitHub Packages, configure `.npmrc` with the `@hyperlinksspace`
@@ -33,12 +34,12 @@ registry and token.
33
34
  ## After Scaffold
34
35
 
35
36
  ```bash
36
- cd my-new-program
37
+ cd new-program
37
38
  npm install
38
39
  npm run start
39
40
  ```
40
41
 
41
- Then open the project `README.md` for full setup details (env vars, bot setup, build
42
+ Then open the project **`fullREADME.md`** for details (env vars, bot setup, build
42
43
  and release commands).
43
44
 
44
45
  ## Release Channels
@@ -50,4 +51,3 @@ and release commands).
50
51
 
51
52
  - Published directly from the `app/` folder.
52
53
  - Package tarball is filtered to include only required project files.
53
- - **`fullREADME.md`** in the package is the full in-repo developer guide (Expo setup, scripts, and the rest of the project readme).
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "url": "https://github.com/HyperlinksSpace/HyperlinksSpaceBot.git"
41
41
  },
42
42
  "main": "expo-router/entry",
43
- "version": "1.2.3",
43
+ "version": "1.2.181818",
44
44
  "type": "module",
45
45
  "engines": {
46
46
  "node": ">=18 <=22"
@@ -200,7 +200,7 @@
200
200
  "@vercel/functions": "^3.4.3",
201
201
  "concurrently": "^9.1.0",
202
202
  "cross-env": "^7.0.3",
203
- "dotenv": "^16.4.5",
203
+ "dotenv": "^16.6.1",
204
204
  "electron": "^41.0.4",
205
205
  "electron-builder": "^26.8.1",
206
206
  "electron-forge": "^5.2.4",
@@ -4,14 +4,12 @@ import path from "path";
4
4
  /**
5
5
  * Unified env loader for local Node contexts.
6
6
  *
7
- * Loads .env and .env.local from repo root and app/.
7
+ * Loads .env and .env.local from repo root.
8
8
  * On Vercel, these files normally aren't present, so this is effectively a no-op.
9
9
  */
10
10
  export function loadEnv() {
11
11
  const cwd = process.cwd();
12
12
  dotenv.config({ path: path.join(cwd, ".env") });
13
- dotenv.config({ path: path.join(cwd, "app", ".env") });
14
13
  dotenv.config({ path: path.join(cwd, ".env.local") });
15
- dotenv.config({ path: path.join(cwd, "app", ".env.local") });
16
14
  }
17
15
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Quick check that app/api/base.ts works. Run: npx tsx scripts/test-api-base.ts
2
+ * Quick check that api/base.ts works. Run: npx tsx scripts/test-api-base.ts
3
3
  * In Node (no window), getApiBaseUrl() uses Vercel env or falls back to http://localhost:3000.
4
4
  */
5
5
  import { getApiBaseUrl, buildApiUrl } from "../api/base.js";
package/tsconfig.json CHANGED
@@ -14,4 +14,4 @@
14
14
  ".expo/types/**/*.ts",
15
15
  "expo-env.d.ts"
16
16
  ]
17
- }
17
+ }
package/windows/build.cjs CHANGED
@@ -2115,7 +2115,7 @@ async function createWindow() {
2115
2115
 
2116
2116
  // NSIS close-app uses PRODUCT_NAME (package.json → build.productName). The window title must
2117
2117
  // match that string, not a URL — otherwise the installer cannot find/close the running app.
2118
- // Keep in sync with app/package.json "build.productName".
2118
+ // Keep in sync with package.json "build.productName".
2119
2119
  const windowTitle = isDev ? "http://www.hyperlinks.space/" : brand.productDisplayName;
2120
2120
 
2121
2121
  const mainWindow = new BrowserWindow({
@@ -1,7 +1,7 @@
1
1
  # Remove leftover per-user installs under %LOCALAPPDATA%\Programs\ and updater sidecars.
2
2
  # Older builds often installed to AppData while current NSIS uses perMachine -> Program Files.
3
3
  #
4
- # Usage (from app/):
4
+ # Usage (from repo root):
5
5
  # powershell -ExecutionPolicy Bypass -File .\windows\cleanup-legacy-appdata-installs.ps1 # list only
6
6
  # powershell -ExecutionPolicy Bypass -File .\windows\cleanup-legacy-appdata-installs.ps1 -Force # delete
7
7
  # If removal fails with "in use", close the app or run with -KillAppProcesses (stops exes under those folders).
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Single source of truth for Windows/Electron product naming.
3
- * Display name and artifact slug come from app/package.json → build.productName.
3
+ * Display name and artifact slug come from package.json → build.productName.
4
4
  */
5
5
  const fs = require("fs");
6
6
  const path = require("path");