Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/Bridge/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,29 @@
if (!jid) return null
return { type: 'markChatAsReadUpdate', jid, read: asBoolOr(extractAction(data)?.read, true) }
},
label_edit_update: data => {

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / run-tests

Parameter 'data' implicitly has an 'any' type.

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / run-tests

Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / check-lint

Parameter 'data' implicitly has an 'any' type.

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / check-lint

Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / build

Parameter 'data' implicitly has an 'any' type.

Check failure on line 294 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / build

Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.
const labelId = asString(data.label_id)
if (!labelId) return { type: 'noop', bridgeType: 'label_edit_update' }
const action = extractAction(data)
// `predefinedId` is proto `predefined_id` (a number); upstream `Label`
// wants it as a string. Dual-read the spelling, then stringify.
const predefined = asNumber(action?.predefinedId ?? action?.predefined_id)
return {
type: 'labelEdit',
labelId,
name: asString(action?.name) ?? '',
color: asNumber(action?.color) ?? 0,
deleted: asBoolOr(action?.deleted, false),
predefinedId: predefined != null ? String(predefined) : undefined
}
},
label_association_update: data => {

Check failure on line 310 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / run-tests

Parameter 'data' implicitly has an 'any' type.

Check failure on line 310 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / check-lint

Parameter 'data' implicitly has an 'any' type.

Check failure on line 310 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / build

Parameter 'data' implicitly has an 'any' type.
const labelId = asString(data.label_id)
const chatJid = asJidString(data.chat_jid)
if (!labelId || !chatJid) return { type: 'noop', bridgeType: 'label_association_update' }
// `action.labeled === true` → label added to the chat, else removed.
return { type: 'labelAssociation', labelId, chatJid, labeled: asBoolOr(extractAction(data)?.labeled, true) }
},
Comment on lines +294 to +316

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

❓ Verification inconclusive

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Show relevant part of schema.ts around the reported lines
sed -n '250,360p' src/Bridge/schema.ts | nl -ba

# 2) Find where ADAPTERS and AdapterMap are declared and how TS2353 is triggered
rg -n "ADAPTERS|satisfies AdapterMap|AdapterMap|WhatsAppEvent\\['type'\\]|WhatsAppEvent" src/Bridge/schema.ts src/Bridge -S

# 3) Search for label_edit_update / label_association_update in the repo
rg -n "label_edit_update|label_association_update" -S .

# 4) Check package.json and lockfile for whatsapp-rust-bridge version
ls -la
rg -n "\"whatsapp-rust-bridge\"|whatsapp-rust-bridge" package.json pnpm-lock.yaml yarn.lock package-lock.json -S || true

Repository: oxidezap/baileyrs

Length of output: 104


🏁 Script executed:

ls -la

Repository: oxidezap/baileyrs

Length of output: 1403


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '250,360p' src/Bridge/schema.ts | nl -ba

rg -n "ADAPTERS|satisfies AdapterMap|AdapterMap|WhatsAppEvent\\['type'\\]|WhatsAppEvent" src/Bridge/schema.ts src/Bridge -S

rg -n "label_edit_update|label_association_update" -S .

ls -la
rg -n "\"whatsapp-rust-bridge\"|whatsapp-rust-bridge" package.json pnpm-lock.yaml yarn.lock package-lock.json -S || true

Repository: oxidezap/baileyrs

Length of output: 104


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '250,360p' src/Bridge/schema.ts | nl -ba

rg -n "ADAPTERS|satisfies AdapterMap|AdapterMap|WhatsAppEvent\\['type'\\]|WhatsAppEvent" src/Bridge/schema.ts src/Bridge -S

rg -n "label_edit_update|label_association_update" -S .

ls -la
rg -n "\"whatsapp-rust-bridge\"|whatsapp-rust-bridge" package.json pnpm-lock.yaml yarn.lock package-lock.json -S || true

Repository: oxidezap/baileyrs

Length of output: 104


🏁 Script executed:

...

Repository: oxidezap/baileyrs

Length of output: 105


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Context around the reported lines
sed -n '260,340p' src/Bridge/schema.ts | nl -ba

# Find the type-level constraints that would trigger TS2353
rg -n "ADAPTERS|satisfies AdapterMap|type AdapterMap|interface AdapterMap|WhatsAppEvent\\b|\\['type'\\]" src/Bridge/schema.ts src/Bridge -S

# See how often these keys appear elsewhere
rg -n "label_edit_update|label_association_update" -S .

# Determine the current whatsapp-rust-bridge version from manifests/lockfiles
ls -la
rg -n "\"whatsapp-rust-bridge\"|whatsapp-rust-bridge" package.json pnpm-lock.yaml yarn.lock package-lock.json -S || true

Repository: oxidezap/baileyrs

Length of output: 104


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print schema.ts around the reported lines with line numbers (no `nl` available)
sed -n '260,340p' src/Bridge/schema.ts | awk '{printf "%6d\t%s\n", NR+259, $0}'

# Locate the type constraints and where the adapter map is defined
rg -n "ADAPTERS|AdapterMap|satisfies AdapterMap|WhatsAppEvent\\b|\\['type'\\]" src/Bridge/schema.ts src/Bridge -S

# Check whether the specific adapter keys exist elsewhere
rg -n "label_edit_update|label_association_update" -S src/Bridge src || true

# Get whatsapp-rust-bridge version info from package.json / lockfile
cat package.json
rg -n "\"whatsapp-rust-bridge\"" package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true

Repository: oxidezap/baileyrs

Length of output: 13085


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect ADAPTERS declaration and the satisfies clause location
sed -n '90,160p' src/Bridge/schema.ts | awk '{printf "%6d\t%s\n", NR+89, $0}'
sed -n '450,520p' src/Bridge/schema.ts | awk '{printf "%6d\t%s\n", NR+449, $0}'

# 2) Check whether node_modules (and whatsapp-rust-bridge typings) exist in this sandbox
ls -la node_modules >/dev/null 2>&1 && echo "node_modules exists" || echo "node_modules missing"

if [ -d "node_modules/whatsapp-rust-bridge" ]; then
  # 3) Search typings for the specific discriminator strings
  rg -n "label_edit_update|label_association_update" node_modules/whatsapp-rust-bridge -S || true
  # 4) Show where WhatsAppEvent type is declared (roughly)
  rg -n "export type WhatsAppEvent|type WhatsAppEvent|interface WhatsAppEvent" node_modules/whatsapp-rust-bridge -S || true
fi

# 3) Open the drift test to understand how it reads the WhatsAppEvent union from installed .d.ts
sed -n '1,120p' src/Bridge/__tests__/dts-drift.test.ts | awk '{printf "%6d\t%s\n", NR, $0}'

Repository: oxidezap/baileyrs

Length of output: 10937


🌐 Web query:

whatsapp-rust-bridge label_edit_update label_association_update

💡 Result:

I couldn’t find any authoritative documentation or source code in whatsapp-rust-bridge (or its referenced variants) that defines the exact labels you provided: “label_edit_update” and “label_association_update”. The only relevant “label” items found were about WhatsApp label app-state syncing and unrelated “label*_update” identifiers in other ecosystems (e.g., HubSpot CRM association labels, Gmail API label updates), which appear to be different domains. What I can say from the sources: 1) whatsapp-rust-bridge is an ongoing Rust/WASM project, but the specific event/handler names “label_edit_update” and “label_association_update” are not surfaced in the material located by this search. 2) There is evidence that some WhatsApp stacks expose label app-state events/handlers in general (e.g., a PR titled “Forward WhatsApp label appstate events to webhooks”). However, it does not confirm those exact identifier strings. If you tell me where these strings appear (e.g., a particular repository path, a file name like constants.ts, protobuf field names, or a webhook payload example), I can do a targeted second pass to identify the precise mapping to whatsapp-rust-bridge’s API/event system.

Citations:


🌐 Web query:

whatsapp_rust_bridge.d.ts "label_edit_update"

💡 Result:

I couldn’t find any source that mentions the symbol/label “label_edit_update” inside whatsapp_rust_bridge.d.ts (or anywhere else in the searched repositories/docs). The search results surfaced the package/type definition files’ presence (e.g., a generated whatsapp_rust_bridge.d.ts under a published npm package), but not the specific string “label_edit_update”. If you can share either (a) the exact npm package name/version that contains whatsapp_rust_bridge.d.ts, or (b) paste the contents of whatsapp_rust_bridge.d.ts (or at least the section around where you expect “label_edit_update”), I can pinpoint whether that member exists, what its TypeScript type is, and where it maps in Rust/wasm.

Citations:


Bridge adapter keys likely don’t exist in whatsapp-rust-bridge’s WhatsAppEvent['type'] union (TS2353).

src/Bridge/schema.ts adds ADAPTERS.label_edit_update and ADAPTERS.label_association_update (lines 294-316), but ADAPTERS is typed as satisfies AdapterMap where AdapterMap is keyed by WhatsAppEvent['type']. If the installed whatsapp-rust-bridge typings don’t include these exact discriminator strings in whatsapp_rust_bridge.d.ts, the build will fail (TS2353 / related type errors).

Check node_modules/whatsapp-rust-bridge/pkg/whatsapp_rust_bridge.d.ts for label_edit_update and label_association_update. If missing, bump/pin whatsapp-rust-bridge so the union includes them and update package-lock.json (the lockfile contains entries for both 0.6.0-alpha.36 and 0.5.4). Otherwise, temporarily gate these adapters until the dependency version used in CI exports the required event types.

🧰 Tools
🪛 GitHub Actions: Build Project / 0_build.txt

[error] 294-294: TypeScript compilation failed (tsc). TS2353: Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Actions: Build Project / build

[error] 294-294: TypeScript (TS2353) build failed. Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Actions: Linting Check / 0_check-lint.txt

[error] 294-294: TypeScript build failed (tsc). TS2353: Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Actions: Linting Check / check-lint

[error] 294-294: TypeScript (tsc) error TS2353: Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Actions: Run Tests / 0_run-tests.txt

[error] 294-294: TypeScript error TS2353: Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'. The build command 'tsc -P tsconfig.build.json' failed.

🪛 GitHub Actions: Run Tests / run-tests

[error] 294-294: TypeScript (tsc) error TS2353: Object literal may only specify known properties. Property 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Check: build

[failure] 310-310:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Check: check-lint

[failure] 310-310:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🪛 GitHub Check: run-tests

[failure] 310-310:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Parameter 'data' implicitly has an 'any' type.


[failure] 294-294:
Object literal may only specify known properties, and 'label_edit_update' does not exist in type 'AdapterMap'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Bridge/schema.ts` around lines 294 - 316, The new adapter keys
label_edit_update and label_association_update added to ADAPTERS conflict with
the WhatsAppEvent['type'] union (typed via AdapterMap) and will cause TS2353 if
those discriminators are not present in the installed whatsapp-rust-bridge
types; either upgrade/pin whatsapp-rust-bridge so its d.ts includes
"label_edit_update" and "label_association_update" (and update package-lock.json
to a version that exports them) or guard these entries behind a
runtime/type-safe check (temporarily remove or conditionally register
ADAPTERS.label_edit_update and ADAPTERS.label_association_update until the
dependency is bumped) so the build doesn’t reference event strings not present
in the installed typings.


// ── Calls ──
incoming_call: (data, logger) => adaptIncomingCall(data, logger),
Expand Down Expand Up @@ -398,6 +421,16 @@
const jid = asJidString(data.jid)
return jid ? { type: 'chatDelete', jid } : { type: 'noop', bridgeType: 'delete_chat_update' }
},
clear_chat_update: data => {

Check failure on line 424 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / run-tests

Parameter 'data' implicitly has an 'any' type.

Check failure on line 424 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / check-lint

Parameter 'data' implicitly has an 'any' type.

Check failure on line 424 in src/Bridge/schema.ts

View workflow job for this annotation

GitHub Actions / build

Parameter 'data' implicitly has an 'any' type.
// Clear = drop all messages but keep the chat. Maps to upstream
// `messages.delete` `{ jid, all: true }` (the chat-clear surface noted in
// the messageDelete dispatcher), distinct from chatDelete (whole chat gone).
const jid = asJidString(data.jid)
return jid ? { type: 'chatClear', jid } : { type: 'noop', bridgeType: 'clear_chat_update' }
},
// Muting a contact's status (stories) updates. Forwarded for surface completeness,
// but noop'd: upstream Baileys has no status-mute event/chatModify to map it onto.
user_status_mute_update: () => ({ type: 'noop', bridgeType: 'user_status_mute_update' }),
delete_message_for_me_update: data => {
const chatJid = asJidString(data.chat_jid)
const messageId = asString(data.message_id)
Expand Down Expand Up @@ -579,6 +612,7 @@
*/
const RECEIPT_TYPE_MAP: Record<string, NonNullable<import('./types.ts').CanonicalReceipt['receiptType']>> = {
Delivered: 'delivered',
Sent: 'sent',
Sender: 'sender',
Retry: 'retry',
EncRekeyRetry: 'enc-rekey-retry',
Expand All @@ -591,6 +625,7 @@
HistorySync: 'history-sync',
ServerError: 'server-error',
delivered: 'delivered',
sent: 'sent',
sender: 'sender',
retry: 'retry',
enc_rekey_retry: 'enc-rekey-retry',
Expand Down
38 changes: 38 additions & 0 deletions src/Bridge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export interface CanonicalReceipt {
*/
receiptType?:
| 'delivered'
| 'sent'
| 'sender'
| 'retry'
| 'enc-rekey-retry'
Expand Down Expand Up @@ -474,6 +475,12 @@ export interface CanonicalChatDelete {
jid: string
}

/** A chat's messages were cleared (the chat itself is kept) via app-state sync. */
export interface CanonicalChatClear {
type: 'chatClear'
jid: string
}

/** "Delete for me" of a single message via app-state sync. */
export interface CanonicalMessageDelete {
type: 'messageDelete'
Expand Down Expand Up @@ -564,6 +571,34 @@ export interface CanonicalNoop {

// ── Union ──

// ── Labels ──

/**
* A label was created, renamed/recolored, or deleted on a linked device
* (bridge `label_edit_update`). Maps to upstream `labels.edit` (`Label`).
*/
export interface CanonicalLabelEdit {
type: 'labelEdit'
labelId: string
name: string
color: number
deleted: boolean
/** Predefined-label id, stringified to match upstream `Label.predefinedId`. */
predefinedId?: string
}

/**
* A label was associated with / removed from a chat on a linked device
* (bridge `label_association_update`). Maps to upstream `labels.association`.
*/
export interface CanonicalLabelAssociation {
type: 'labelAssociation'
labelId: string
chatJid: string
/** `true` = label added to the chat, `false` = removed. */
labeled: boolean
}

export type CanonicalEvent =
| CanonicalConnected
| CanonicalDisconnected
Expand All @@ -590,11 +625,14 @@ export type CanonicalEvent =
| CanonicalMuteUpdate
| CanonicalStarUpdate
| CanonicalMarkChatAsReadUpdate
| CanonicalLabelEdit
| CanonicalLabelAssociation
| CanonicalIncomingCall
| CanonicalUndecryptableMessage
| CanonicalLidMappingUpdate
| CanonicalNewsletterLiveUpdate
| CanonicalChatDelete
| CanonicalChatClear
| CanonicalMessageDelete
| CanonicalDisappearingModeChanged
| CanonicalHistorySync
Expand Down
26 changes: 23 additions & 3 deletions src/Socket/chat-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* Compatibility wrapper for original Baileys chatModify API.
* Routes to the appropriate bridge method based on the modification type.
*
* Fully supported: archive, pin, mute, star, markRead, delete, deleteForMe, pushNameSetting
* Not yet in bridge (app-state patches): clear, contact, disableLinkPreviews, labels, quickReply
* Fully supported: archive, pin, mute, star, markRead, delete, deleteForMe, pushNameSetting, contact, clear
* Not yet in bridge (app-state patches): disableLinkPreviews, labels, quickReply
Comment on lines +25 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Documentation claims are premature without bridge dependency update.

The updated documentation marks contact and clear as "Fully supported," but both client.saveContact and client.clearChat are missing from the current whatsapp-rust-bridge@0.6.0-alpha.36 types. This documentation should be updated in the same PR that bumps the bridge dependency, or carry a note that it requires an updated bridge version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Socket/chat-actions.ts` around lines 25 - 26, The comment claiming "Fully
supported" for actions including contact and clear is inaccurate because
client.saveContact and client.clearChat aren't available in the current
whatsapp-rust-bridge@0.6.0-alpha.36; update the doc comment in
src/Socket/chat-actions.ts to either remove contact and clear from the "Fully
supported" list or add a short note stating these two require a bridge
dependency bump to a version that exports client.saveContact and
client.clearChat (reference symbols: contact, clear, client.saveContact,
client.clearChat, whatsapp-rust-bridge@0.6.0-alpha.36), and ensure this change
is made in the same PR that updates the bridge dependency.

Source: Linters/SAST tools

*/
chatModify: async (mod: ChatModification, jid: string) => {
const client = await ctx.getClient()
Expand All @@ -45,9 +45,29 @@
await client.deleteMessageForMe(jid, mod.deleteForMe.key.id!, !!mod.deleteForMe.key.fromMe)
} else if ('pushNameSetting' in mod) {
await client.setPushName(mod.pushNameSetting)
} else if ('contact' in mod) {
// Save/rename a contact (syncs the name to linked devices). `jid` is the
// contact's bare PN jid. `contact: null` (removal) has no bridge/core path
// yet, so it is ignored.
if (mod.contact) {
await client.saveContact(

Check failure on line 53 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / run-tests

Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 53 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / check-lint

Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 53 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / build

Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.
jid,
mod.contact.fullName ?? undefined,
mod.contact.firstName ?? undefined,
mod.contact.saveOnPrimaryAddressbook ?? true
)
Comment on lines +53 to +58

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the current bridge version in package.json and verify method availability

echo "=== Current bridge version in package.json ==="
cat package.json | jq -r '.dependencies["whatsapp-rust-bridge"]'

echo -e "\n=== Searching for saveContact usage in codebase ==="
rg -n "saveContact" --type ts

echo -e "\n=== Checking bridge type definitions ==="
fd -e d.ts -e ts "node_modules/whatsapp-rust-bridge" --exec cat {} \; | rg -A5 -B5 "saveContact|WasmWhatsAppClient" || echo "Bridge types not found or method not defined"

Repository: oxidezap/baileyrs

Length of output: 323


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== node_modules/whatsapp-rust-bridge existence ==="
if [ -d "node_modules/whatsapp-rust-bridge" ]; then
  echo "node_modules/whatsapp-rust-bridge exists"
  ls -la node_modules/whatsapp-rust-bridge | head
else
  echo "node_modules/whatsapp-rust-bridge does NOT exist"
fi

echo -e "\n=== List lockfiles ==="
ls -ლა package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true

echo -e "\n=== Resolved bridge version from lockfile (best-effort) ==="
if [ -f "pnpm-lock.yaml" ]; then
  rg -n "whatsapp-rust-bridge" pnpm-lock.yaml | head -n 20
elif [ -f "yarn.lock" ]; then
  rg -n "whatsapp-rust-bridge" yarn.lock | head -n 20
elif [ -f "package-lock.json" ]; then
  rg -n "whatsapp-rust-bridge" package-lock.json | head -n 20
else
  echo "No lockfile found."
fi

echo -e "\n=== Search for WasmWhatsAppClient typings in repo (excluding node_modules) ==="
rg -n "WasmWhatsAppClient" --type ts --type d.ts --hidden -g'!**/node_modules/**' || true

echo -e "\n=== Search for saveContact in repo (excluding node_modules) ==="
rg -n "saveContact" --type ts --type d.ts --hidden -g'!**/node_modules/**' || true

Repository: oxidezap/baileyrs

Length of output: 906


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== List lockfiles (correct flags) ==="
ls -la package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true

echo -e "\n=== Detect likely lockfile name(s) ==="
find . -maxdepth 2 -type f -name "*lock*" -print | head -n 50

# Determine which lockfile exists
LOCKFILE=""
if [ -f "pnpm-lock.yaml" ]; then LOCKFILE="pnpm-lock.yaml"; fi
if [ -f "yarn.lock" ] && [ -z "$LOCKFILE" ]; then LOCKFILE="yarn.lock"; fi
if [ -f "package-lock.json" ] && [ -z "$LOCKFILE" ]; then LOCKFILE="package-lock.json"; fi
echo -e "\n=== Using lockfile: ${LOCKFILE:-<none>} ==="

if [ -n "$LOCKFILE" ]; then
  echo -e "\n=== Lines referencing whatsapp-rust-bridge in $LOCKFILE ==="
  rg -n "whatsapp-rust-bridge" "$LOCKFILE" | head -n 80
fi

echo -e "\n=== Attempt to fetch/install package tarball contents (npm pack) ==="
# Best-effort: if network/npm is unavailable, this will fail and we’ll fall back to web_search later.
rm -rf /tmp/whatsapp-rust-bridge-tmp && mkdir -p /tmp/whatsapp-rust-bridge-tmp
cd /tmp/whatsapp-rust-bridge-tmp

npm pack whatsapp-rust-bridge@0.6.0-alpha.36 >/tmp/pack_stdout.txt 2>/tmp/pack_stderr.txt || true
echo "npm pack stderr (tail):"
tail -n 30 /tmp/pack_stderr.txt || true

TARBALL="$(ls -1 *.tgz 2>/dev/null | head -n 1 || true)"
echo -e "\nPacked tarball: ${TARBALL:-<none>}"

if [ -n "${TARBALL:-}" ]; then
  tar -xzf "$TARBALL"
  echo -e "\n=== Extracted package top-level ==="
  ls -la | head

  echo -e "\n=== Search extracted typings for WasmWhatsAppClient/saveContact ==="
  rg -n "WasmWhatsAppClient|saveContact" . --hidden || true

  echo -e "\n=== List .d.ts files that mention WasmWhatsAppClient ==="
  rg -n --files-with-matches "WasmWhatsAppClient" . --hidden || true
fi

Repository: oxidezap/baileyrs

Length of output: 3106


🏁 Script executed:

#!/bin/bash
set -euo pipefail

WORKDIR="/tmp/whatsapp-bridge-inspect-0.6.0-alpha.36"
rm -rf "$WORKDIR"
mkdir -p "$WORKDIR"
cd "$WORKDIR"

npm pack whatsapp-rust-bridge@0.6.0-alpha.36 >/tmp/pack2_stdout.txt 2>/tmp/pack2_stderr.txt || true
TARBALL="$(ls -1 *.tgz | head -n 1)"
tar -xzf "$TARBALL"

echo "=== Search for saveContact in extracted typings ==="
rg -n "saveContact" . || true

echo -e "\n=== Search for any 'save' methods on WasmWhatsAppClient (context) ==="
rg -n "interface WasmWhatsAppClient|class WasmWhatsAppClient|save[A-Za-z0-9_]*\\(" package/pkg/whatsapp_rust_bridge.d.ts || true

echo -e "\n=== If saveContact exists, show surrounding declaration ==="
# Print a small context block around any saveContact occurrences (if any)
if rg -n "saveContact" package/pkg/whatsapp_rust_bridge.d.ts >/dev/null 2>&1; then
  rg -n -C 5 "saveContact" package/pkg/whatsapp_rust_bridge.d.ts
fi

Repository: oxidezap/baileyrs

Length of output: 320


Bridge method saveContact is missing from WasmWhatsAppClient typings (whatsapp-rust-bridge@0.6.0-alpha.36).

The call to client.saveContact(...) in src/Socket/chat-actions.ts won’t type-check: the whatsapp-rust-bridge@0.6.0-alpha.36 TypeScript definitions (dist/index.d.ts / pkg/whatsapp_rust_bridge.d.ts) contain WasmWhatsAppClient but no saveContact method, so CI compilation is expected to fail unless the bridge dependency is bumped to a version that exports this API (or the code is switched to an existing method).

🧰 Tools
🪛 GitHub Check: build

[failure] 53-53:
Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.

🪛 GitHub Check: check-lint

[failure] 53-53:
Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.

🪛 GitHub Check: run-tests

[failure] 53-53:
Property 'saveContact' does not exist on type 'WasmWhatsAppClient'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Socket/chat-actions.ts` around lines 53 - 58, The call to
client.saveContact in src/Socket/chat-actions.ts fails TypeScript because
WasmWhatsAppClient in whatsapp-rust-bridge@0.6.0-alpha.36 has no saveContact
definition; either upgrade the bridge dependency to a version that exports
saveContact or add a local declaration merging for the WasmWhatsAppClient
interface that declares saveContact(jid: string, fullName?: string, firstName?:
string, saveOnPrimaryAddressbook?: boolean): Promise<void> so the call
type-checks; update package.json and lockfile if bumping the bridge, or add the
interface augmentation file (e.g., global .d.ts) referencing WasmWhatsAppClient
to expose saveContact.

Source: Linters/SAST tools

}
} else if ('clear' in mod) {
// Clear a chat's messages while keeping the chat. `lastMessages` (the
// message range) is ignored, same as the `delete` branch — the bridge
// clears the whole chat. deleteStarred/deleteMedia aren't part of the
// Baileys `clear` shape, so default both to false (keep starred + media).
if (mod.clear) {
await client.clearChat(jid, false, false)

Check failure on line 66 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / run-tests

Property 'clearChat' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 66 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / check-lint

Property 'clearChat' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 66 in src/Socket/chat-actions.ts

View workflow job for this annotation

GitHub Actions / build

Property 'clearChat' does not exist on type 'WasmWhatsAppClient'.
}
} else {
// App-state-patch variants not yet exposed by bridge:
// clear, contact, disableLinkPreviews, addLabel, addChatLabel,
// disableLinkPreviews, addLabel, addChatLabel,
// removeChatLabel, addMessageLabel, removeMessageLabel, quickReply
const variant = Object.keys(mod)[0]
ctx.logger.warn(
Expand Down
3 changes: 3 additions & 0 deletions src/Socket/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
/** PN counterpart, present when the server returned a LID as primary JID. */
pnJid?: string
isBusiness?: boolean
/** Verified business name (from usync `<business><verified_name>`), present for verified businesses. */
verifiedName?: string
}

export const makeContactMethods = (ctx: SocketContext) => ({
Expand All @@ -19,6 +21,7 @@
const out: OnWhatsAppResult = { exists: r.isRegistered, jid: r.jid, isBusiness: r.isBusiness }
if (r.lid) out.lid = r.lid
if (r.pnJid) out.pnJid = r.pnJid
if (r.verifiedName) out.verifiedName = r.verifiedName

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / run-tests

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / run-tests

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / check-lint

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / check-lint

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / build

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.

Check failure on line 24 in src/Socket/contacts.ts

View workflow job for this annotation

GitHub Actions / build

Property 'verifiedName' does not exist on type 'IsOnWhatsAppResult'.
return out
})
},
Expand Down
19 changes: 19 additions & 0 deletions src/Socket/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
WAPresence
} from '../Types/index.ts'
import { DisconnectReason, WAProto } from '../Types/index.ts'
import { LabelAssociationType } from '../Types/LabelAssociation.ts'
import { Boom } from '../Utils/boom.ts'
import { toNumber } from '../Utils/generics.ts'
import { isJidGroup } from '../WABinary/jid-utils.ts'
Expand Down Expand Up @@ -501,6 +502,23 @@ const DISPATCHERS: DispatcherMap = {
// Mirrors upstream `chat-utils.ts:852`: read=true → unreadCount=0,
// read=false (mark as unread) → -1 sentinel.
ctx.ev.emit('chats.update', [{ id: evt.jid, unreadCount: evt.read ? 0 : -1 }]),
labelEdit: (evt, { ctx }) =>
// Upstream `labels.edit` carries a `Label`. A delete arrives with
// `deleted: true` (consumers remove it from their store).
ctx.ev.emit('labels.edit', {
id: evt.labelId,
name: evt.name,
color: evt.color,
deleted: evt.deleted,
predefinedId: evt.predefinedId
}),
labelAssociation: (evt, { ctx }) =>
// Inbound sync only ever carries chat associations (the bridge event
// has a `chat_jid`); message-label associations are a separate path.
ctx.ev.emit('labels.association', {
association: { type: LabelAssociationType.Chat, chatId: evt.chatJid, labelId: evt.labelId },
type: evt.labeled ? 'add' : 'remove'
}),

// ── Calls ──
incomingCall: (evt, { ctx }) => {
Expand Down Expand Up @@ -571,6 +589,7 @@ const DISPATCHERS: DispatcherMap = {
}
},
chatDelete: (evt, { ctx }) => ctx.ev.emit('chats.delete', [evt.jid]),
chatClear: (evt, { ctx }) => ctx.ev.emit('messages.delete', { jid: evt.jid, all: true }),
messageDelete: (evt, { ctx }) =>
// Upstream `chat-utils.ts:857` shape: `{ keys: WAMessageKey[] }` for
// per-message delete (not the `{ jid, all: true }` chat-clear case
Expand Down
3 changes: 2 additions & 1 deletion src/Socket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@
handleEvent,
bridgeStore,
fullConfig.cache ?? null,
fullConfig.version
fullConfig.version,
fullConfig.wantedPreKeyCount ?? null

Check failure on line 393 in src/Socket/index.ts

View workflow job for this annotation

GitHub Actions / run-tests

Expected 2-6 arguments, but got 7.

Check failure on line 393 in src/Socket/index.ts

View workflow job for this annotation

GitHub Actions / check-lint

Expected 2-6 arguments, but got 7.

Check failure on line 393 in src/Socket/index.ts

View workflow job for this annotation

GitHub Actions / build

Expected 2-6 arguments, but got 7.
)
// Make this client the fallback for standalone helpers like
// downloadContentFromMessage that have no socket reference.
Expand Down
24 changes: 21 additions & 3 deletions src/Socket/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@
* Send a receipt for messages. The bridge handles most receipt types automatically
* (delivered, sender). Use `readMessages` for the common case of sending read receipts.
*
* Supported types via bridge: 'read', 'read-self'
* Supported types via bridge: 'read', 'read-self', 'played'
* Auto-handled by bridge: 'sender', 'inactive', undefined (delivered)
* Not supported: 'played', 'hist_sync', 'peer_msg' (logged as warning)
* Not supported: 'hist_sync', 'peer_msg' (logged as warning)
*/
sendReceipt: async (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => {
if (!messageIds.length) return
Expand All @@ -225,9 +225,20 @@
...(participant ? { participant } : {})
}))
await (await ctx.getClient()).readMessages(keys)
} else if (type === 'played') {
// Voice/video-note played receipts. The bridge (and core) pick the wire
// type (`played` vs `played-self` for newsletters) and the `participant`
// attr from the chat jid, so we just hand over the keys — same shape as
// readMessages.
const keys = messageIds.map(id => ({
remoteJid: jid,
id,
...(participant ? { participant } : {})
}))
await (await ctx.getClient()).markPlayed(keys)

Check failure on line 238 in src/Socket/messages.ts

View workflow job for this annotation

GitHub Actions / run-tests

Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 238 in src/Socket/messages.ts

View workflow job for this annotation

GitHub Actions / check-lint

Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.

Check failure on line 238 in src/Socket/messages.ts

View workflow job for this annotation

GitHub Actions / build

Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.
Comment on lines +228 to +238

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for markPlayed method in bridge types

echo "=== Searching for markPlayed in codebase ==="
rg -n "markPlayed" --type ts

echo -e "\n=== Checking bridge type definitions for markPlayed ==="
fd -e d.ts -e ts "node_modules/whatsapp-rust-bridge" --exec cat {} \; | rg -A5 -B5 "markPlayed|readMessages" || echo "Method not found in bridge types"

Repository: oxidezap/baileyrs

Length of output: 340


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== node_modules/whatsapp-rust-bridge existence ==="
ls -la node_modules/whatsapp-rust-bridge 2>/dev/null || echo "node_modules/whatsapp-rust-bridge not present"

echo -e "\n=== Count of .d.ts files under bridge package ==="
if [ -d node_modules/whatsapp-rust-bridge ]; then
  find node_modules/whatsapp-rust-bridge -name "*.d.ts" | wc -l
else
  echo 0
fi

echo -e "\n=== Search for markPlayed in bridge package ==="
if [ -d node_modules/whatsapp-rust-bridge ]; then
  rg -n "markPlayed" node_modules/whatsapp-rust-bridge --hidden --glob '!*node_modules/**/node_modules/*' || echo "No markPlayed symbol found"
else
  echo "Skipping (bridge package missing)"
fi

echo -e "\n=== Search for readMessages / played receipt related symbols in bridge package ==="
if [ -d node_modules/whatsapp-rust-bridge ]; then
  rg -n "readMessages|played|receipt" node_modules/whatsapp-rust-bridge --hidden --glob '!*node_modules/**/node_modules/*' | head -n 50 || echo "No related symbols found"
else
  echo "Skipping (bridge package missing)"
fi

Repository: oxidezap/baileyrs

Length of output: 413


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Find WasmWhatsAppClient import/definition in repo ==="
rg -n "WasmWhatsAppClient" -S --hidden --glob '!.git/*' .

echo -e "\n=== Search for markPlayed in repo (all files) ==="
rg -n "markPlayed" -S --hidden --glob '!.git/*' . 

echo -e "\n=== Search for readMessages / played receipt related methods ==="
rg -n "readMessages|played.*receipt|mark.*Played" -S --hidden --glob '!.git/*' src

echo -e "\n=== Inspect TypeScript client wrapper/type exports (candidate files) ==="
# Common patterns: bridge wrapper types might live near src/bridge or in a generated types folder.
ls -ლა src | head -n 200 || true
fd -e ts -e d.ts "WasmWhatsAppClient" -S src node_modules 2>/dev/null || true

Repository: oxidezap/baileyrs

Length of output: 4307


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== src/Socket/messages.ts (context around readMessages/sendReceipt/sendReceipts) ==="
sed -n '170,310p' src/Socket/messages.ts | nl -ba

echo -e "\n=== src/Socket/types.ts ==="
sed -n '1,120p' src/Socket/types.ts | nl -ba

echo -e "\n=== src/Socket/index.ts (type alias usage) ==="
sed -n '1,80p' src/Socket/index.ts | nl -ba

Repository: oxidezap/baileyrs

Length of output: 208


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== src/Socket/messages.ts (context around readMessages/sendReceipt/sendReceipts) ==="
sed -n '170,310p' src/Socket/messages.ts | cat -n

echo -e "\n=== src/Socket/types.ts ==="
sed -n '1,140p' src/Socket/types.ts | cat -n

echo -e "\n=== src/Socket/index.ts (type alias usage) ==="
sed -n '1,120p' src/Socket/index.ts | cat -n

Repository: oxidezap/baileyrs

Length of output: 12158


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "=== package.json ==="
cat package.json | rg -n "whatsapp-rust-bridge|dependencies|devDependencies" -n || true
echo -e "\n=== Full dependency lines mentioning whatsapp-rust-bridge (package-lock/yarn/pnpm) ==="
ls -la | rg -n "package-lock.json|yarn.lock|pnpm-lock.yaml" || true
rg -n "\"whatsapp-rust-bridge\"|whatsapp-rust-bridge" package-lock.json yarn.lock pnpm-lock.yaml 2>/dev/null || true

Repository: oxidezap/baileyrs

Length of output: 884


🌐 Web query:

whatsapp-rust-bridge 0.6.0-alpha.36 WasmWhatsAppClient markPlayed

💡 Result:

I couldn’t find any authoritative/public source that documents the symbol WasmWhatsAppClient.markPlayed specifically for whatsapp-rust-bridge version 0.6.0-alpha.36. The only clearly documented “markPlayed” function I found in the broader WhatsApp ecosystem is in the WPPConnect JS libraries (separate project), e.g. WPP.chat.markPlayed/WAJS.chat.markPlayed are exported there to mark a message as played [1][2]. What I did find about whatsapp-rust-bridge versions: - Public metadata I found for whatsapp-rust-bridge was for version 0.6.0-alpha.25 (not alpha.36) [3]. - I found the main whatsapp-rust-bridge GitHub repo, but the search results shown didn’t surface a 0.6.0-alpha.36 release tag/changelog entry nor the exact WasmWhatsAppClient.markPlayed method definition for that version [4]. For “markPlayed” behavior in WhatsApp clients generally, there is an upstream concept of sending a “played” receipt; for example, whatsmeow has code that uses receipt type “played” via MarkRead with ptt=true [5]. If you want, paste the repository link (or the generated WASM/TS bindings file) that contains WasmWhatsAppClient, or the relevant snippet from alpha.36, and I can map exactly what markPlayed does and how it’s wired to the underlying receipt/protocol for that specific release.

Citations:


🌐 Web query:

unpkg whatsapp-rust-bridge@0.6.0-alpha.36 WasmWhatsAppClient markPlayed

💡 Result:

I couldn’t find authoritative evidence that a symbol named WasmWhatsAppClient (with a method/property markPlayed) exists in whatsapp-rust-bridge@0.6.0-alpha.36. What I could verify from sources: 1) The public JS API concept of “mark message as played” is present in wppconnect/wa-js under chat.markPlayed, but that is not part of whatsapp-rust-bridge [1][2]. 2) For whatsapp-rust-bridge, I found commit activity and general package pages, but the search results available to me did not expose the unpkg/module source for whatsapp-rust-bridge@0.6.0-alpha.36, nor any code that mentions WasmWhatsAppClient or markPlayed in that version [3][4]. Therefore, I can’t reliably answer what unpkg whatsapp-rust-bridge@0.6.0-alpha.36 exports regarding WasmWhatsAppClient.markPlayed. If you want, paste the output of this from your environment (or the relevant unpkg file contents) and I’ll pinpoint the exact export/method names: - https://unpkg.com/whatsapp-rust-bridge@0.6.0-alpha.36/ - https://unpkg.com/whatsapp-rust-bridge@0.6.0-alpha.36/dist/index.js (or whatever entry file exists) - any file containing WasmWhatsAppClient or markPlayed.

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== npm pack whatsapp-rust-bridge@0.6.0-alpha.36 ==="
rm -f /tmp/whatsapp-rust-bridge-*.tgz
if command -v npm >/dev/null 2>&1; then
  npm pack whatsapp-rust-bridge@0.6.0-alpha.36 --silent
else
  echo "npm not available"
  exit 0
fi

TARBALL="$(ls -1 *.tgz 2>/dev/null | head -n 1 || true)"
if [ -z "${TARBALL:-}" ]; then
  # maybe npm created in cwd with a name, but pattern might differ; search recursively in cwd
  TARBALL="$(find . -maxdepth 2 -type f -name "whatsapp-rust-bridge-*.tgz" | head -n 1 || true)"
fi
echo -e "\nTarball: ${TARBALL:-<none>}"

if [ -z "${TARBALL:-}" ]; then
  exit 0
fi

echo -e "\n=== Inspect tarball contents (look for d.ts / WasmWhatsAppClient / markPlayed) ==="
mkdir -p /tmp/bridge_inspect
tar -xzf "$TARBALL" -C /tmp/bridge_inspect

# Count and list declaration files
echo -e "\n-- .d.ts files --"
find /tmp/bridge_inspect -type f -name "*.d.ts" | wc -l
find /tmp/bridge_inspect -type f -name "*.d.ts" | head -n 50

echo -e "\n-- Search for WasmWhatsAppClient in package --"
rg -n "WasmWhatsAppClient" /tmp/bridge_inspect --hidden --no-ignore  || echo "No WasmWhatsAppClient string found"

echo -e "\n-- Search for markPlayed in package declarations/runtime --"
rg -n "markPlayed" /tmp/bridge_inspect --hidden --no-ignore || echo "No markPlayed string found"

echo -e "\n-- Search for played receipt helpers (played/read) --"
rg -n "played.*receipt|receipt.*played|Read.*played|mark.*played|Played" /tmp/bridge_inspect --hidden --no-ignore | head -n 80 || true

Repository: oxidezap/baileyrs

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

TAR_DIR="/tmp/bridge_inspect"
DTS="$TAR_DIR/package/pkg/whatsapp_rust_bridge.d.ts"

echo "=== Sanity: declaration file exists ==="
ls -ლა "$DTS" 2>/dev/null || (echo "missing $DTS"; exit 1)

echo -e "\n=== Methods containing 'read' in WasmWhatsAppClient declarations ==="
rg -n "readMessages|markRead|mark.*Read|played|mark.*Played|Receipt" "$DTS" | head -n 200

echo -e "\n=== Extract WasmWhatsAppClient interface section around readMessages ==="
LINE_READ=$(rg -n "readMessages" "$DTS" | head -n 1 | cut -d: -f1 || true)
if [ -n "${LINE_READ:-}" ]; then
  START=$((LINE_READ-40))
  END=$((LINE_READ+80))
  sed -n "${START},${END}p" "$DTS" | nl -ba | head -n 200
else
  echo "No readMessages found in $DTS"
fi

echo -e "\n=== Extract WasmWhatsAppClient class section around readMessages (if present) ==="
LINE_READ_C=$(rg -n "class WasmWhatsAppClient" "$DTS" | head -n 1 | cut -d: -f1 || true)
if [ -n "${LINE_READ_C:-}" ]; then
  sed -n "${LINE_READ_C},$((LINE_READ_C+220))p" "$DTS" | nl -ba | head -n 220
fi

echo -e "\n=== Search for literal 'markPlayed' in d.ts only ==="
rg -n "markPlayed" "$DTS" || echo "markPlayed not present in d.ts"

Repository: oxidezap/baileyrs

Length of output: 167


🏁 Script executed:

#!/bin/bash
set -euo pipefail

TARBALL="whatsapp-rust-bridge-0.6.0-alpha.36.tgz"
if [ ! -f "$TARBALL" ]; then
  echo "Missing $TARBALL in cwd. Please re-run npm pack first."
  exit 1
fi

rm -rf /tmp/bridge_inspect
mkdir -p /tmp/bridge_inspect
tar -xzf "$TARBALL" -C /tmp/bridge_inspect

echo "=== Dump candidate d.ts paths ==="
find /tmp/bridge_inspect -type f -name "*whatsapp_rust_bridge*.d.ts" -o -name "*.d.ts" | head -n 50

DTS="$(find /tmp/bridge_inspect -type f -name "whatsapp_rust_bridge.d.ts" | head -n 1 || true)"
if [ -z "${DTS:-}" ]; then
  echo "Could not find whatsapp_rust_bridge.d.ts under /tmp/bridge_inspect"
  exit 1
fi

echo -e "\nUsing: $DTS"

echo -e "\n=== Literal markPlayed occurrences in d.ts ==="
rg -n "markPlayed" "$DTS" || echo "markPlayed not present in d.ts"

echo -e "\n=== Receipt/played/read-related declarations (read/played/receipt) ==="
rg -n "readMessages|markRead|played|receipt|read.*self" "$DTS" | head -n 200

echo -e "\n=== Show WasmWhatsAppClient interface snippet around readMessages (if found) ==="
if rg -n "readMessages" "$DTS" >/dev/null; then
  LINE_READ=$(rg -n "readMessages" "$DTS" | head -n 1 | cut -d: -f1)
  START=$((LINE_READ-60))
  END=$((LINE_READ+140))
  sed -n "${START},${END}p" "$DTS" | cat -n
else
  echo "No readMessages in d.ts"
fi

Repository: oxidezap/baileyrs

Length of output: 8376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

DTS="/tmp/bridge_inspect/package/pkg/whatsapp_rust_bridge.d.ts"
if [ ! -f "$DTS" ]; then
  echo "Missing $DTS"
  exit 1
fi

echo "=== Methods containing 'Played'/'played' in name ==="
rg -n "played" "$DTS" | head -n 80

echo -e "\n=== Methods containing 'mark' in name ==="
rg -n "mark[A-Za-z0-9_]*\\(" "$DTS" | head -n 120

echo -e "\n=== Lines mentioning 'readMessages' and surrounding receipt comments ==="
LINE=$(rg -n "readMessages\\(" "$DTS" | head -n 1 | cut -d: -f1)
if [ -n "${LINE:-}" ]; then
  START=$((LINE-120))
  END=$((LINE+140))
  sed -n "${START},${END}p" "$DTS" | nl -ba | head -n 220
fi

Repository: oxidezap/baileyrs

Length of output: 416


🏁 Script executed:

#!/bin/bash
set -euo pipefail

DTS="/tmp/bridge_inspect/package/pkg/whatsapp_rust_bridge.d.ts"
if [ ! -f "$DTS" ]; then
  echo "Missing $DTS"
  exit 1
fi

echo "=== Methods containing 'Receipt' ==="
rg -n "Receipt" "$DTS" | head -n 120

echo -e "\n=== Methods containing 'read' and 'receipt' keywords near each other ==="
rg -n "readMessages|played|receipt" "$DTS" | head -n 200

echo -e "\n=== Methods around readMessages declaration ==="
LINE=$(rg -n "readMessages\\(" "$DTS" | head -n 1 | cut -d: -f1 || true)
if [ -n "${LINE:-}" ]; then
  START=$((LINE-80))
  END=$((LINE+120))
  sed -n "${START},${END}p" "$DTS" | cat -n | head -n 220
fi

echo -e "\n=== Methods containing 'mark' (case-insensitive) besides markChatAsRead ==="
rg -n -i "mark[A-Za-z0-9_]*\\(" "$DTS" | head -n 120

Repository: oxidezap/baileyrs

Length of output: 11274


Fix missing bridge API: WasmWhatsAppClient.markPlayed doesn’t exist (bridge 0.6.0-alpha.36).

src/Socket/messages.ts calls client.markPlayed(...) in both sendReceipt (type played) and sendReceipts (type played), but whatsapp-rust-bridge@0.6.0-alpha.36’s WasmWhatsAppClient type declarations contain readMessages(...) and markChatAsRead(...)—there is no markPlayed symbol—so TypeScript will fail compilation.

🧰 Tools
🪛 GitHub Check: build

[failure] 238-238:
Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.

🪛 GitHub Check: check-lint

[failure] 238-238:
Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.

🪛 GitHub Check: run-tests

[failure] 238-238:
Property 'markPlayed' does not exist on type 'WasmWhatsAppClient'.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Socket/messages.ts` around lines 228 - 238, The code calls
WasmWhatsAppClient.markPlayed(...) (in sendReceipt/sendReceipts handling type
'played') but that API does not exist in whatsapp-rust-bridge@0.6.0-alpha.36;
replace the markPlayed invocation with the existing readMessages(...) call using
the same keys shape (the keys object you build for played receipts matches
readMessages), i.e., call (await ctx.getClient()).readMessages(keys) instead of
markPlayed, and update any related type references from markPlayed to
readMessages to satisfy TypeScript and bridge typings (references: sendReceipt,
sendReceipts, WasmWhatsAppClient, readMessages, markChatAsRead).

Source: Linters/SAST tools

} else {
// delivered/sender/inactive receipts are sent automatically by the Rust bridge
// played/hist_sync/peer_msg require bridge-side support
// hist_sync/peer_msg require bridge-side support
ctx.logger.debug(
{ type, jid, count: messageIds.length },
'sendReceipt: type handled automatically by bridge or not yet supported'
Expand All @@ -248,6 +259,13 @@
if (readKeys.length) {
await client.readMessages(readKeys)
}
} else if (type === 'played') {
const playedKeys = keys
.filter(k => !k.fromMe && k.remoteJid && k.id)
.map(k => ({ remoteJid: k.remoteJid!, id: k.id!, ...(k.participant ? { participant: k.participant } : {}) }))
if (playedKeys.length) {
await client.markPlayed(playedKeys)
}
} else {
ctx.logger.debug(
{ type, count: keys.length },
Expand Down
8 changes: 8 additions & 0 deletions src/Socket/newsletter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,13 @@ export const makeNewsletterMethods = (ctx: SocketContext) => ({

newsletterReactMessage: async (jid: string, serverId: string, reaction?: string) => {
await (await ctx.getClient()).newsletterReactMessage(jid, serverId, reaction ?? null)
},

/**
* Mute or unmute a newsletter (channel) — silences its follower-activity
* notifications, the mute a subscriber toggles. `mute = true` silences.
*/
newsletterMute: async (jid: string, mute: boolean) => {
await (await ctx.getClient()).newsletterMute(jid, mute)
}
})
8 changes: 8 additions & 0 deletions src/Types/Socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ export type SocketConfig = {
*/
deviceProps?: DevicePropsInput

/**
* Number of one-time pre-keys generated and uploaded per batch. Defaults to
* WhatsApp Web's 812; clamped to the protocol-safe range at upload time.
* Lower it to cut memory/CPU of the first pre-key upload (the whole batch is
* generated and encoded in one shot). Must be set before connecting.
*/
wantedPreKeyCount?: number

// ─────────────────────────────────────────────────────────────────────
// Upstream-Baileys options accepted for type-level compatibility.
//
Expand Down
Loading