viber-channel 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bridge_core.ts +6 -1
- package/lib/dm_stream.ts +8 -1
- package/package.json +1 -1
- package/viber-channel.ts +1 -0
package/lib/bridge_core.ts
CHANGED
|
@@ -561,7 +561,12 @@ export async function sseLoop(opts: {
|
|
|
561
561
|
async function reconcileMessages(): Promise<boolean> {
|
|
562
562
|
let msgs: Array<Record<string, unknown>>;
|
|
563
563
|
try {
|
|
564
|
-
|
|
564
|
+
// #333: catch-up is a REST call to GET /api/conversations/:id/messages,
|
|
565
|
+
// which is served by the Worker API (baseUrl) — NOT by minted.ws_url, which
|
|
566
|
+
// is the SSE/voice host (the CF tunnel in staging/prod). Using ws_url here
|
|
567
|
+
// 404s whenever the SSE host differs from the API host (masked in dev where
|
|
568
|
+
// they collapse to one origin). The SSE subscription still uses ws_url.
|
|
569
|
+
msgs = await fetchMessages(baseUrl, minted.conversation_id, runtime.token);
|
|
565
570
|
} catch (err) {
|
|
566
571
|
if (err instanceof ConversationTokenExpiredError) throw err;
|
|
567
572
|
process.stderr.write(`${logPrefix} catch-up fetch failed: ${safeErrorMessage(err)}\n`);
|
package/lib/dm_stream.ts
CHANGED
|
@@ -35,7 +35,14 @@ export type FetchMessagesFn = (
|
|
|
35
35
|
) => Promise<Array<Record<string, unknown>>>;
|
|
36
36
|
|
|
37
37
|
export interface DmStreamOptions {
|
|
38
|
+
/** SSE/voice host (CF tunnel in staging/prod) — used for the events stream. */
|
|
38
39
|
wsUrl: string;
|
|
40
|
+
/**
|
|
41
|
+
* Worker API host — used for the REST catch-up (GET /:id/messages). This is a
|
|
42
|
+
* DIFFERENT origin from `wsUrl` in staging/prod (the messages route lives on
|
|
43
|
+
* the Worker, not the SSE tunnel); collapsing them caused #333's catch-up 404.
|
|
44
|
+
*/
|
|
45
|
+
apiBaseUrl: string;
|
|
39
46
|
conversationId: string;
|
|
40
47
|
conversationToken: string;
|
|
41
48
|
onMessage: (msg: DmMessage) => void | Promise<void>;
|
|
@@ -135,7 +142,7 @@ async function catchUp(opts: DmStreamOptions, handledIds: Set<string>): Promise<
|
|
|
135
142
|
const doFetch = opts.fetchMessagesImpl ?? fetchMessages;
|
|
136
143
|
let msgs: Array<Record<string, unknown>>;
|
|
137
144
|
try {
|
|
138
|
-
msgs = await doFetch(opts.
|
|
145
|
+
msgs = await doFetch(opts.apiBaseUrl, opts.conversationId, opts.conversationToken);
|
|
139
146
|
} catch (err) {
|
|
140
147
|
if (err instanceof ConversationTokenExpiredError) throw new DmStreamAuthError();
|
|
141
148
|
opts.log?.(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viber-channel",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Voice + text MCP channel between a Claude Code session and the Viber UI (https://viber.dgypx.dev). Push transcripts to Claude; send_message tool delivers text back to the UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/viber-channel.ts
CHANGED
|
@@ -977,6 +977,7 @@ function startDmStream(minted: ConversationMintResponse): void {
|
|
|
977
977
|
// per-DM conversation heartbeat (#298) was removed in #315.
|
|
978
978
|
void runDmStream({
|
|
979
979
|
wsUrl: minted.ws_url,
|
|
980
|
+
apiBaseUrl: BASE_URL,
|
|
980
981
|
conversationId: minted.conversation_id,
|
|
981
982
|
conversationToken: minted.conversation_token,
|
|
982
983
|
log: (m) => process.stderr.write(m),
|