shadok-ai 0.20.11 → 0.20.13

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/README.md CHANGED
@@ -454,7 +454,11 @@ Enter to skip; you can add it later from the web UI).
454
454
  served back to the browser by `GET /media/<name>` from the same directory
455
455
  Telegram attachments land in. On a multi-tenant instance each group has its own
456
456
  media directory (`/media/g-<group>/<name>`), readable only by that group's
457
- agents and served only to people who can see that group.
457
+ agents and served only to people who can see that group. Every agent is
458
+ started with that directory as an extra working directory (`--add-dir`), so
459
+ it reads what you sent **without asking for permission** — and nothing is
460
+ written into its project or worktree. An agent started before this change
461
+ needs one *Reload agent* to pick it up.
458
462
  - **Files an agent hands you** — when an agent's result IS a file (a report, an
459
463
  export, a screenshot, an archive) it arrives as a download card in the chat,
460
464
  inline if it is an image, and as an upload in the Telegram topic. It goes
@@ -923,6 +927,52 @@ from the board group's creator, so an instance that already has an owner never
923
927
  hands itself to whoever messages next — a bot username is public, and a DM is a
924
928
  shell.
925
929
 
930
+ ### WhatsApp (optional, linking only for now)
931
+
932
+ The **WhatsApp** panel (in the ⋯ menu, beside Telegram, admin only) links ONE
933
+ WhatsApp number to the instance. Linking makes the instance a **linked device**
934
+ of that account, the way WhatsApp Web is: click **Link a number**, then on the
935
+ phone open *Settings → Linked devices → Link a device* and scan the code the
936
+ panel shows (it refreshes by itself; nobody scanning for three minutes ends the
937
+ attempt). The panel then shows who the instance is linked as and since when;
938
+ **Unlink** logs the device out on WhatsApp's side and deletes the stored session
939
+ — even when that logout cannot reach WhatsApp, in which case remove the device
940
+ from the phone's *Linked devices* list too.
941
+
942
+ - **Use a number you can afford to lose.** This is not WhatsApp's official API:
943
+ linking a device this way is outside WhatsApp's terms of use, and the number
944
+ can be restricted or banned. The panel says so before you link.
945
+ - **One number, one instance.** Nothing stops the same account from being linked
946
+ to two instances, and both would answer — don't.
947
+ - **Only linking exists so far.** Messages are not handled yet; anyone-who-writes-
948
+ gets-their-own-agent (the WhatsApp twin of Telegram's open DMs) comes next.
949
+ - The panel always shows the link's true state, one at a time: *Not linked*,
950
+ *Linking*, *Connected*, *Reconnecting* (a link that stops answering leaves
951
+ *Connected* within about two minutes, even with no disconnect event),
952
+ *Unlinked remotely* (removed from the phone), *Stopped* with the reason (WhatsApp
953
+ refused the number, the same number was connected elsewhere, a local failure, or
954
+ a previous start that went down while resuming — nothing is retried on its own;
955
+ **Retry** or **Link again** is your call), *Installing the WhatsApp library*,
956
+ *WhatsApp library needed* with the reason, or *Unavailable* with the reason.
957
+ **Unlink** is offered whenever a session is stored, in every state.
958
+ - **Multi-tenant, migrated instances only.** The stored session IS the account,
959
+ so it must be out of every agent's reach: it lives in
960
+ `~/.shadok-ai/whatsapp/<instance>/` (mode 0700, on the data volume, so a
961
+ recreate does not unlink the number), and the feature is refused on a
962
+ mono-tenant instance and until the groups migration has completed.
963
+ - **The WhatsApp library is installed on demand, not with shadok-ai.** Neither
964
+ `npx shadok-ai` nor the auto-update fetches any WhatsApp package: an instance
965
+ that never links a number installs nothing. The first **Link** by an admin runs
966
+ `npm ci` (about 35 MB on disk, a few seconds on a good connection) into
967
+ `~/.shadok-ai/whatsapp-lib/` on the data volume, so it survives updates and
968
+ recreates. The versions and the whole package tree are pinned by the release
969
+ (by checksum), install scripts are off, and the machine needs `npm` and access
970
+ to the npm registry. A failed install says why (no network, no npm, a full
971
+ disk) and offers **Install** again. When a release pins a new version, the old
972
+ copy is never used: the panel asks you to **Install** before the link
973
+ reconnects. The same happens when a stored session finds no library at boot,
974
+ because nothing is ever installed without an admin's click.
975
+
926
976
  ### Running in Docker
927
977
 
928
978
  > Putting one instance online for someone else, on its own machine, behind a
@@ -1530,6 +1580,7 @@ machine, which silently shifts every daily prompt on a server running in UTC.
1530
1580
  | `SHADOK_AUTOUPDATE=0` | don't apply a newer release by itself (**ON by default** under the supervisor, i.e. `npx shadok-ai`; a server run directly never self-updates, since nothing would respawn it). `0`/`false` turns it off, `1`/`true` forces it on; the GUI setting wins over either once used |
1531
1581
  | `SHADOK_PILOT_PROMPT=0` | don't inject the cockpit system prompt |
1532
1582
  | `SHADOK_GREETING=0` | the lead agent starts silent — no first-message greeting |
1583
+ | `SHADOK_WA_FAKE=1` | **verification only**: the WhatsApp panel drives a scripted fake transport instead of the library (no phone, no real account), and `POST /whatsapp/fake/:action` scripts it — for checking the panel on a side instance |
1533
1584
  | `SHADOK_LEDGER=0` | turn OFF the shared-ledger reflex — a per-instance state table siblings read/write so they stop re-surfacing resolved work, plus a `⟦ledger⟧` delta pushed ahead of each message (**ON by default**; `SHADOK_LEDGER=0` or the GUI/config setting turns it off) |
1534
1585
  | `SHADOK_SEED_SKILLS=0` | don't rewrite the machine-wide skill scripts at boot — for a build run side by side with another instance, so it doesn't hand that instance's agents scripts newer than the server they call |
1535
1586
  | `SHADOK_RESUME_SUMMARY=1` | don't auto-answer the resume-from-summary prompt |
@@ -1754,7 +1805,9 @@ to — from the profile's editor or from a tick on the secret's *Injected into*
1754
1805
  chips, both directions of the same link — and which agent **received** it at spawn or in a cron guard, with the person
1755
1806
  or door that caused it; names only, never a value; filters `secret`, `action`,
1756
1807
  `actor`, `agent`, `since`, `limit`. Also in the vault panel → *Audit log*, and
1757
- 🕘 on each secret), `/telegram`, `/defaults`, `/first-agent` (GET —
1808
+ 🕘 on each secret), `/telegram`, `/whatsapp` (GET — the link's state, the QR drawn
1809
+ as SVG only for a signed-in admin's browser; POST/DELETE `/whatsapp/link` — link,
1810
+ cancel or unlink, admin and browser-only), `/defaults`, `/first-agent` (GET —
1758
1811
  `{pending, reason}`: whether this instance's lead agent is being started
1759
1812
  right now), `/version`, `/autoupdate`,
1760
1813
  `/connect/status` (GET — `{available, providers: {linkedin, google, github},
@@ -0,0 +1,13 @@
1
+ // The entry of the on-demand WhatsApp library directory (src/wa-library.ts).
2
+ //
3
+ // Copied beside package.json and npm-shrinkwrap.json into
4
+ // ~/.shadok-ai/whatsapp-lib/<fingerprint>/, where `npm ci` installs the tree.
5
+ // A dynamic import() resolves from the module that makes it, so importing the
6
+ // packages HERE resolves them from that directory's node_modules — never from
7
+ // the app's own, which the auto-update rewrites and which no longer carries them.
8
+ const ALLOWED = new Set(["baileys", "qrcode"]);
9
+
10
+ export function load(name) {
11
+ if (!ALLOWED.has(name)) return Promise.reject(new Error(`not a package of this directory: ${name}`));
12
+ return import(name);
13
+ }