Compare commits
5 Commits
fix/presen
...
b659dadb9e
| Author | SHA1 | Date | |
|---|---|---|---|
| b659dadb9e | |||
| 20e55849eb | |||
| d47d3467df | |||
| 7dc70522d1 | |||
| 2acb084ee4 |
13
dist/fabric/src/channel.js
vendored
13
dist/fabric/src/channel.js
vendored
@@ -117,6 +117,19 @@ export const fabricChannelPlugin = createChatChannelPlugin({
|
|||||||
resolveAccount: (cfg, accountId) => resolveFabricAccount(cfg, accountId),
|
resolveAccount: (cfg, accountId) => resolveFabricAccount(cfg, accountId),
|
||||||
defaultAccountId: (cfg) => resolveDefaultFabricAccountId(cfg),
|
defaultAccountId: (cfg) => resolveDefaultFabricAccountId(cfg),
|
||||||
isConfigured: (account) => Boolean(account.fabricApiKey),
|
isConfigured: (account) => Boolean(account.fabricApiKey),
|
||||||
|
// openclaw's channelManager.getRuntimeSnapshot() — called every minute
|
||||||
|
// by the channel-health-monitor — defaults `configured: true` when the
|
||||||
|
// plugin doesn't expose describeAccount (see applyDescribedAccountFields
|
||||||
|
// in server-channels). Without this, fabric's synthetic 'default'
|
||||||
|
// account (returned by listFabricAccountIds when channels.fabric.accounts
|
||||||
|
// is empty — the prod shape) gets snapshot {enabled:true, configured:true,
|
||||||
|
// running:false} → isManagedAccount=true → not-running → restart loop
|
||||||
|
// every ~10 min, logging `[fabric:default] health-monitor: restarting`.
|
||||||
|
// Mirror isConfigured here so the snapshot truthfully reports false for
|
||||||
|
// any account without a fabricApiKey.
|
||||||
|
describeAccount: (account) => ({
|
||||||
|
configured: Boolean(account.fabricApiKey),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
// Minimal setup adapter: Fabric is configured directly under
|
// Minimal setup adapter: Fabric is configured directly under
|
||||||
// channels.fabric.* (no interactive wizard). applyAccountConfig is the
|
// channels.fabric.* (no interactive wizard). applyAccountConfig is the
|
||||||
|
|||||||
19
dist/fabric/src/inbound.js
vendored
19
dist/fabric/src/inbound.js
vendored
@@ -261,9 +261,26 @@ export class FabricInbound {
|
|||||||
const tok = session.guildAccessTokens.find((t) => t.guildNodeId === g.nodeId)?.token;
|
const tok = session.guildAccessTokens.find((t) => t.guildNodeId === g.nodeId)?.token;
|
||||||
if (!tok)
|
if (!tok)
|
||||||
continue;
|
continue;
|
||||||
|
// Use the *callback* form of `auth` so socket.io re-evaluates the JWT
|
||||||
|
// on every (re)connect. The single-shot `auth: { token: tok }` shape
|
||||||
|
// captured the token in closure: after socket.io's silent auto-reconnect
|
||||||
|
// the backend got the same JWT that expired ~15 min into the session
|
||||||
|
// (guildAccessToken TTL = 900s) and silently rejected the handshake at
|
||||||
|
// the application layer. The client's `connect` event still fired (TCP
|
||||||
|
// succeeded), so the plugin happily ran the channel-resync, emitted
|
||||||
|
// `join_channel` into the void, and logged "joined N channel(s)" while
|
||||||
|
// the backend was actually broadcasting message.created to a room with
|
||||||
|
// zero subscribers. End user symptom: DMs to agents silently dropped.
|
||||||
const socket = io(`${g.endpoint}/realtime`, {
|
const socket = io(`${g.endpoint}/realtime`, {
|
||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
auth: { token: tok },
|
auth: (cb) => {
|
||||||
|
// Best-effort fresh token; on transient failure fall back to the
|
||||||
|
// last known good one. tokenCache also keeps HTTP calls (attachment
|
||||||
|
// download / reply post) from 401'ing in the same window.
|
||||||
|
this.freshGuildToken(agentId, g.nodeId, session)
|
||||||
|
.then((fresh) => cb({ token: fresh ?? tok }))
|
||||||
|
.catch(() => cb({ token: tok }));
|
||||||
|
},
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
});
|
});
|
||||||
// Tracked socket.io rooms for this (agent, guild). The initial fetch
|
// Tracked socket.io rooms for this (agent, guild). The initial fetch
|
||||||
|
|||||||
@@ -153,6 +153,19 @@ export const fabricChannelPlugin = createChatChannelPlugin<ResolvedFabricAccount
|
|||||||
resolveAccount: (cfg, accountId) => resolveFabricAccount(cfg as never, accountId),
|
resolveAccount: (cfg, accountId) => resolveFabricAccount(cfg as never, accountId),
|
||||||
defaultAccountId: (cfg) => resolveDefaultFabricAccountId(cfg as never),
|
defaultAccountId: (cfg) => resolveDefaultFabricAccountId(cfg as never),
|
||||||
isConfigured: (account: ResolvedFabricAccount) => Boolean(account.fabricApiKey),
|
isConfigured: (account: ResolvedFabricAccount) => Boolean(account.fabricApiKey),
|
||||||
|
// openclaw's channelManager.getRuntimeSnapshot() — called every minute
|
||||||
|
// by the channel-health-monitor — defaults `configured: true` when the
|
||||||
|
// plugin doesn't expose describeAccount (see applyDescribedAccountFields
|
||||||
|
// in server-channels). Without this, fabric's synthetic 'default'
|
||||||
|
// account (returned by listFabricAccountIds when channels.fabric.accounts
|
||||||
|
// is empty — the prod shape) gets snapshot {enabled:true, configured:true,
|
||||||
|
// running:false} → isManagedAccount=true → not-running → restart loop
|
||||||
|
// every ~10 min, logging `[fabric:default] health-monitor: restarting`.
|
||||||
|
// Mirror isConfigured here so the snapshot truthfully reports false for
|
||||||
|
// any account without a fabricApiKey.
|
||||||
|
describeAccount: (account: ResolvedFabricAccount) => ({
|
||||||
|
configured: Boolean(account.fabricApiKey),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
// Minimal setup adapter: Fabric is configured directly under
|
// Minimal setup adapter: Fabric is configured directly under
|
||||||
// channels.fabric.* (no interactive wizard). applyAccountConfig is the
|
// channels.fabric.* (no interactive wizard). applyAccountConfig is the
|
||||||
|
|||||||
@@ -325,9 +325,26 @@ export class FabricInbound {
|
|||||||
for (const g of session.guilds) {
|
for (const g of session.guilds) {
|
||||||
const tok = session.guildAccessTokens.find((t) => t.guildNodeId === g.nodeId)?.token;
|
const tok = session.guildAccessTokens.find((t) => t.guildNodeId === g.nodeId)?.token;
|
||||||
if (!tok) continue;
|
if (!tok) continue;
|
||||||
|
// Use the *callback* form of `auth` so socket.io re-evaluates the JWT
|
||||||
|
// on every (re)connect. The single-shot `auth: { token: tok }` shape
|
||||||
|
// captured the token in closure: after socket.io's silent auto-reconnect
|
||||||
|
// the backend got the same JWT that expired ~15 min into the session
|
||||||
|
// (guildAccessToken TTL = 900s) and silently rejected the handshake at
|
||||||
|
// the application layer. The client's `connect` event still fired (TCP
|
||||||
|
// succeeded), so the plugin happily ran the channel-resync, emitted
|
||||||
|
// `join_channel` into the void, and logged "joined N channel(s)" while
|
||||||
|
// the backend was actually broadcasting message.created to a room with
|
||||||
|
// zero subscribers. End user symptom: DMs to agents silently dropped.
|
||||||
const socket = io(`${g.endpoint}/realtime`, {
|
const socket = io(`${g.endpoint}/realtime`, {
|
||||||
transports: ['websocket'],
|
transports: ['websocket'],
|
||||||
auth: { token: tok },
|
auth: (cb) => {
|
||||||
|
// Best-effort fresh token; on transient failure fall back to the
|
||||||
|
// last known good one. tokenCache also keeps HTTP calls (attachment
|
||||||
|
// download / reply post) from 401'ing in the same window.
|
||||||
|
this.freshGuildToken(agentId, g.nodeId, session)
|
||||||
|
.then((fresh) => cb({ token: fresh ?? tok }))
|
||||||
|
.catch(() => cb({ token: tok }));
|
||||||
|
},
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
});
|
});
|
||||||
// Tracked socket.io rooms for this (agent, guild). The initial fetch
|
// Tracked socket.io rooms for this (agent, guild). The initial fetch
|
||||||
|
|||||||
Reference in New Issue
Block a user