beeos-claw 0.6.14 → 0.6.16
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/dist/acp-gateway/bridge-core.js +1 -1
- package/dist/acp-gateway/gateway-events.js +1 -1
- package/dist/acp-server.js +1 -1
- package/dist/config.js +1 -1
- package/dist/im-inbound-handler.js +1 -1
- package/dist/im-runtime-dispatch.js +1 -1
- package/dist/inbound-execution-journal.js +1 -0
- package/dist/index.js +1 -1
- package/dist/message-client-composition.js +1 -0
- package/dist/message-client-types.js +1 -0
- package/dist/message-projection-inbound-consumer.js +1 -0
- package/dist/runtime/conversation-title.js +1 -1
- package/dist/runtime/im-reply-sink.js +1 -1
- package/dist/runtime/message-service-runtime-message-channel.js +1 -1
- package/dist/runtime/ms-runtime-message-channel-adapter.js +1 -1
- package/dist/runtime/ms-runtime-message-channel-consumer-factory.js +1 -1
- package/dist/runtime/runtime-service-production-candidate.js +1 -1
- package/openclaw.plugin.json +1 -5
- package/package.json +2 -2
- package/dist/im-recovery-scanner.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export class MessageServiceRecoveryScanner{client;imInbound;logger;maxConversationsPerScan;maxMessagesPerConversation;pageLimit;agentIdentity="";stopped=!0;scanInFlight=!1;constructor(e){this.client=e.client,this.imInbound=e.imInbound,this.logger=e.logger,this.maxConversationsPerScan=Math.max(1,e.maxConversationsPerScan??100),this.maxMessagesPerConversation=Math.max(1,e.maxMessagesPerConversation??20),this.pageLimit=Math.max(20,Math.min(500,e.pageLimit??200))}start(e){e?(this.agentIdentity=e,this.stopped?(this.stopped=!1,this.trigger("startup")):this.trigger("identity-refresh")):this.logger.warn?.("[beeos-claw] MS recovery scanner not started: empty agent identity")}stop(){this.stopped=!0}trigger(e){!this.stopped&&this.agentIdentity&&this.scan(e)}async scan(e){if(this.scanInFlight)return;this.scanInFlight=!0;const t=Date.now();try{const s=await this.listOpenConversations();let n=0;for(const e of s)n+=await this.recoverConversation(e);this.logger.info?.(`[beeos-claw] MS recovery scan complete reason=${e} conversations=${s.length} recovered=${n} elapsed_ms=${Date.now()-t}`)}catch(t){this.logger.warn?.(`[beeos-claw] MS recovery scan failed reason=${e}: ${t instanceof Error?t.message:String(t)}`)}finally{this.scanInFlight=!1}}async listOpenConversations(){const e=[];let t;do{const s=await this.client.identities.conversations(this.agentIdentity,{state:"open",limit:Math.min(this.maxConversationsPerScan-e.length,100),cursor:t});e.push(...s.conversations),t=s.hasMore?s.nextCursor:void 0}while(t&&e.length<this.maxConversationsPerScan);return e}async recoverConversation(e){const t=await this.loadUnhandledMessages(e.id);if(0===t.length)return 0;let s=0;for(const n of t){if(s>=this.maxMessagesPerConversation)break;"chat_message"===n.type&&(n.sender!==this.agentIdentity&&this.isAddressedToThisAgent(n)&&(this.logger.info?.(`[beeos-claw] MS recovery dispatch conversation=${e.id} message_id=${n.id}`),await this.imInbound.onChatMessage(n),s++))}return s}async loadUnhandledMessages(e){const t=[];let s;for(;t.length<this.maxMessagesPerConversation;){const n=this.maxMessagesPerConversation-t.length,a=await this.listUnhandledMessagePage(e,s,Math.min(this.pageLimit,n));if(t.push(...a.messages),s=a.hasMore?a.nextCursor:void 0,!s)break}return s&&this.logger.warn?.(`[beeos-claw] MS recovery scan capped unhandled messages conversation=${e} count=${t.length}`),t}async listUnhandledMessagePage(e,t,s){const n=new URLSearchParams;n.set("limit",String(s)),n.set("unhandled_by",this.agentIdentity),t&&n.set("cursor",t);const a=await this.client.request("GET",`/api/v2/conversations/${encodeURIComponent(e)}/messages?${n.toString()}`);return{messages:a.messages.map(rawV2MessageToSdkMessage),nextCursor:a.next_cursor,hasMore:a.has_more??!1}}isAddressedToThisAgent(e){const t=e.content??{},s=t.metadata&&"object"==typeof t.metadata?t.metadata:void 0,n="string"==typeof s?.delivery_principal?s.delivery_principal:"";return!n||n===this.agentIdentity}}function rawV2MessageToSdkMessage(e){return{id:String(e.id??""),type:String(e.type??""),sender:String(e.sender??""),conversationId:"string"==typeof e.conversation_id?e.conversation_id:void 0,content:e.content,replyTo:"string"==typeof e.reply_to?e.reply_to:void 0,createdAt:"string"==typeof e.created_at?e.created_at:void 0,updatedAt:"string"==typeof e.updated_at?e.updated_at:void 0,body:"string"==typeof e.body?e.body:void 0,parts:e.parts,state:"string"==typeof e.state?e.state:void 0,stopReason:"string"==typeof e.stop_reason?e.stop_reason:void 0}}
|