feat: add msglib bounded message listing

This commit is contained in:
zhaoyilun
2026-07-10 08:54:11 +08:00
parent c0287fa2e6
commit 44d27879f6
8 changed files with 922 additions and 17 deletions

View File

@@ -49,6 +49,10 @@ $displaySources = $null
$displayEntitySummaries = @()
$messageSources = $null
$messageSourceSummaries = @()
$messageList = $null
$messageListSources = @()
$messageListContentTextNonEmptyCount = 0
$messageListDownloadRefNonEmptyCount = 0
if ($SQLiteDllPath -and $DbPath) {
if (-not (Test-Path -LiteralPath $SQLiteDllPath)) {
throw "SQLite DLL not found: $SQLiteDllPath"
@@ -95,6 +99,31 @@ if ($SQLiteDllPath -and $DbPath) {
}
}
$messageList = Invoke-SidecarJson @{
protocol = "isphere.msglib.v1"
request_id = "verify-list-messages"
op = "list_messages"
args = @{
sqlite_dll_path = $SQLiteDllPath
db_path = $DbPath
password = "123"
conversation_type = "auto"
limit = 5
include_body = $false
include_attachment_metadata = $true
}
}
if (-not $messageList.ok -or -not $messageList.data.read_only -or $messageList.data.message_body_values_returned -or $messageList.data.raw_rows_returned -or $messageList.data.file_paths_returned) {
throw "list_messages failed"
}
$messageListRows = @($messageList.data.messages)
$messageListSources = @($messageList.data.source_tables)
$messageListContentTextNonEmptyCount = @($messageListRows | Where-Object { $_.content_text -or $_.text }).Count
$messageListDownloadRefNonEmptyCount = @($messageListRows | ForEach-Object { @($_.attachments) } | Where-Object { $_.download_ref }).Count
if ($messageListContentTextNonEmptyCount -ne 0 -or $messageListDownloadRefNonEmptyCount -ne 0) {
throw "list_messages returned body text or download refs while include_body=false"
}
foreach ($entityType in @("contacts", "groups")) {
$displayEntities = Invoke-SidecarJson @{
protocol = "isphere.msglib.v1"
@@ -131,6 +160,13 @@ if ($SQLiteDllPath -and $DbPath) {
display_entity_summaries = $displayEntitySummaries
message_source_count = if ($messageSources) { $messageSources.data.message_sources.Count } else { 0 }
message_source_summaries = $messageSourceSummaries
message_list_count = if ($messageList) { @($messageList.data.messages).Count } else { 0 }
message_list_sources = $messageListSources
message_list_body_values_returned = if ($messageList) { [bool]$messageList.data.message_body_values_returned } else { $false }
message_list_raw_rows_returned = if ($messageList) { [bool]$messageList.data.raw_rows_returned } else { $false }
message_list_file_paths_returned = if ($messageList) { [bool]$messageList.data.file_paths_returned } else { $false }
message_list_content_values_omitted = ($messageListContentTextNonEmptyCount -eq 0)
message_list_download_refs_omitted = ($messageListDownloadRefNonEmptyCount -eq 0)
message_body_values_returned = $false
raw_rows_returned = $false
file_paths_returned = $false