Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
81411d7
feat(feat-008): add bounded @/reply shape probe
Eternal-Wanderer-Vegetable Nov 29, 2026
70f9ed5
docs(feat-008): record uncontrolled @/reply shape probe
Eternal-Wanderer-Vegetable Nov 29, 2026
ff72155
docs(feat-008): clarify shape probe evidence wording
Eternal-Wanderer-Vegetable Nov 29, 2026
7cd09af
docs(feat-008): note local init wrapper limitation
Eternal-Wanderer-Vegetable Nov 29, 2026
05061fa
docs(feat-008): record controlled @/reply shape probe
Eternal-Wanderer-Vegetable Nov 30, 2026
fe31860
feat(feat-008): preserve inbound at/reply segments
Eternal-Wanderer-Vegetable Nov 30, 2026
470ec20
docs(feat-008): record inbound at/reply implementation boundary
Eternal-Wanderer-Vegetable Nov 30, 2026
4e24d34
feat(n6a): prepare inbound field validation
Eternal-Wanderer-Vegetable Nov 30, 2026
acecb69
fix(n6a): accept reply element text
Eternal-Wanderer-Vegetable Nov 30, 2026
2397ac7
docs(n6a): record partial inbound field result and reply-fix build
Eternal-Wanderer-Vegetable Nov 30, 2026
597ecf3
feat(n6a): send rich @/reply with exact receipts and local id mapping
Eternal-Wanderer-Vegetable Dec 5, 2026
2307eec
fix(n6a): report empty media readback as unavailable
Eternal-Wanderer-Vegetable Dec 5, 2026
592cdcd
docs(n6a): record unsupported inbound media rejection
Eternal-Wanderer-Vegetable Dec 5, 2026
79d7c45
docs(n6a): record inbound video rejection
Eternal-Wanderer-Vegetable Dec 5, 2026
ee5c252
docs(n6a): update progress with media boundary
Eternal-Wanderer-Vegetable Dec 5, 2026
cf353df
feat(n6b): separate image upload from send with bounded resources
Eternal-Wanderer-Vegetable Dec 5, 2026
3edb395
docs(n6b): record upload HTTP boundary
Eternal-Wanderer-Vegetable Dec 5, 2026
5895032
docs(n6b): record native image send rejection
Eternal-Wanderer-Vegetable Dec 5, 2026
89794f1
fix(n6b): surface image preparation error labels
Eternal-Wanderer-Vegetable Dec 5, 2026
4e7169d
fix(n6b): canonicalize the QQ image cache parent
Eternal-Wanderer-Vegetable Dec 5, 2026
73a6bc6
docs(n6b): record group image send by upload id
Eternal-Wanderer-Vegetable Dec 5, 2026
ddb4035
feat(n6b): observe native image receipt media fields
Eternal-Wanderer-Vegetable Dec 5, 2026
75a2e5a
feat(n6b): persist and expose native image media id
Eternal-Wanderer-Vegetable Dec 5, 2026
ca7709e
docs(n6b): record native image validity boundary
Eternal-Wanderer-Vegetable Dec 5, 2026
8c80ffd
fix(n6b): report persisted image resources as explicitly unavailable
Eternal-Wanderer-Vegetable Dec 5, 2026
358d087
feat(n6c): load media tools in the field soak
Eternal-Wanderer-Vegetable Dec 5, 2026
8e8dbd5
fix(n6c): actually pass media-config to the soak daemon
Eternal-Wanderer-Vegetable Dec 5, 2026
d523e59
docs(n6c): record voice transcode download blockage
Eternal-Wanderer-Vegetable Dec 5, 2026
5b45600
fix(n6c): register incoming PTT callback paths
Eternal-Wanderer-Vegetable Dec 5, 2026
c226120
test(n6c): add bounded voice output shape diagnostics
Eternal-Wanderer-Vegetable Dec 5, 2026
909a1fb
feat(n6c): enable incoming SILK transcription via canonical voice paths
Eternal-Wanderer-Vegetable Dec 5, 2026
2cfd63c
test(n6c): pin explicit rejection for unsupported segments
Eternal-Wanderer-Vegetable Dec 5, 2026
195c140
feat(n6c): probe native media capability names
Eternal-Wanderer-Vegetable Dec 5, 2026
34d9d87
feat(n6c): enumerate native rich-media methods read-only
Eternal-Wanderer-Vegetable Dec 5, 2026
a5b2cdd
docs(n6c): record native upload reference contract
Eternal-Wanderer-Vegetable Dec 5, 2026
0ebd3de
docs(n6c): record inconclusive native upload probe
Eternal-Wanderer-Vegetable Dec 5, 2026
c9cba4d
docs(n6c): record OIDB NTV2 transport blocker
Eternal-Wanderer-Vegetable Dec 5, 2026
e26a164
docs(n6c): keep verified wrapper media path
Eternal-Wanderer-Vegetable Dec 5, 2026
06205a1
feat(n6c): add optional SILK encoder and audio-silk
Eternal-Wanderer-Vegetable Dec 5, 2026
e45d71c
fix(tests): align image and poll budget expectations
Eternal-Wanderer-Vegetable Dec 5, 2026
b7b924e
fix(tests): keep image-chain private path assertion
Eternal-Wanderer-Vegetable Dec 5, 2026
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
37 changes: 36 additions & 1 deletion crates/caligo-bridge/src/daemon_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@ fn capability_messages<A: crate::host_adapter::HostAdapter>(
group_voice: resident.supports_group_voice(),
private_image: resident.supports_image(1),
group_image: resident.supports_image(2),
private_reply: resident.supports_reply(1),
group_reply: resident.supports_reply(2),
group_mention: resident.supports_mention(2),
},
]
}
Expand Down Expand Up @@ -1214,6 +1217,38 @@ fn session_loop<A: crate::host_adapter::HostAdapter>(
outcome:OutcomePayload::Failure {reason:"image dispatch rejected before submission".into()},
}).is_err() {return SessionEnd::Broken;}
}
Ok(CoreToBridgeMsg::DispatchRich { scope,request_id,wire_seq,timeout_ms,chat_type,peer_uin,segments }) => {
c.dispatches += 1;
let has_reply = segments.iter().any(|segment| matches!(segment, caligo_model::onebot_traits::SendSegment::Reply { .. }));
let has_mention = segments.iter().any(|segment| matches!(segment, caligo_model::onebot_traits::SendSegment::Mention { .. }));
let valid = scope == query_scope && wire_seq > 0 && (1..=30_000).contains(&timeout_ms)
&& matches!(chat_type, 1 | 2) && caligo_model::capability::positive_decimal(&peer_uin)
&& (chat_type == 2 || peer_uin != cfg.account)
&& !segments.is_empty()
&& segments.len() <= caligo_model::onebot_traits::MAX_SEND_SEGMENTS
&& (!has_reply || resident.supports_reply(chat_type))
&& (!has_mention || resident.supports_mention(chat_type))
&& segments.iter().all(|segment| match segment {
caligo_model::onebot_traits::SendSegment::Text { .. } => true,
caligo_model::onebot_traits::SendSegment::Mention { qq, uid, name } =>
chat_type == 2
&& !name.is_empty()
&& (qq == "all" && uid == "all"
|| caligo_model::capability::positive_decimal(qq)
&& uid.len() > 2
&& uid.starts_with("u_")),
caligo_model::onebot_traits::SendSegment::Reply { target } =>
target.peer_chat_type == chat_type && target.peer_uin == peer_uin
&& (chat_type != 1 || target.reply_msg_client_seq.is_some()),
});
if valid && resident.submit(crate::resident::OwnedRequest::SendRich {
request_id:request_id.clone(),wire_seq,scope,peer_uin,chat_type,segments,
deadline:Instant::now()+Duration::from_millis(timeout_ms),
}) == crate::resident::SubmitVerdict::Accepted { wake(); }
else if send_json(conn,&BridgeMsg::SendResult {request_id, notice_id: 0,
outcome:OutcomePayload::Failure {reason:"rich dispatch rejected before submission".into()},
}).is_err() {return SessionEnd::Broken;}
}
Ok(message @ (CoreToBridgeMsg::DispatchPrivateVoice { .. } | CoreToBridgeMsg::DispatchGroupVoice { .. })) => {
c.dispatches += 1;
let (chat_type, scope, request_id, wire_seq, timeout_ms, peer_uin, silk, supported) = match message {
Expand Down Expand Up @@ -1551,7 +1586,7 @@ mod tests {
);
let [
BridgeMsg::QueryCapabilities { revision, scope: query_scope, capabilities },
BridgeMsg::SendCapabilities { scope: send_scope, private_text, group_text, private_voice: false, group_voice: false, private_image: false, group_image: false },
BridgeMsg::SendCapabilities { scope: send_scope, private_text, group_text, private_voice: false, group_voice: false, private_image: false, group_image: false, .. },
] = capability_messages(&resident, &expected_scope) else {
panic!("query and send capability announcements missing");
};
Expand Down
14 changes: 14 additions & 0 deletions crates/caligo-bridge/src/host_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ pub enum HostOp {
chat_type: u32,
png: Vec<u8>,
},
SendRich {
request_id: String,
wire_seq: u32,
timeout_ms: u64,
peer_uin: String,
chat_type: u32,
segments: Vec<caligo_model::onebot_traits::SendSegment>,
},
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -130,6 +138,12 @@ pub trait HostAdapter {
fn supports_image(&self, _chat_type: u32) -> bool {
false
}
fn supports_reply(&self, _chat_type: u32) -> bool {
false
}
fn supports_mention(&self, _chat_type: u32) -> bool {
false
}
/// Cancel a pending wrapper query on the owner thread.
fn cancel_query(&mut self, _request_id: &str, _scope: &QueryScope) {}
/// Execute one fixed read-only query on the owner thread.
Expand Down
2 changes: 1 addition & 1 deletion crates/caligo-bridge/src/native_resident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl HostAdapter for NativeHostAdapter {
HostOp::ListenerAdd => Ok(HostOpResult::ListenerDeferred),
// 延迟模式下 resident 不持有监听器 token,不会到达;到达即如实确认。
HostOp::ListenerRemove { .. } => Ok(HostOpResult::ListenerRemoved),
HostOp::SendVoice { .. } | HostOp::SendImage { .. } => Err(HostError::NoProvenRoute),
HostOp::SendVoice { .. } | HostOp::SendImage { .. } | HostOp::SendRich { .. } => Err(HostError::NoProvenRoute),
HostOp::SendText {
request_id,
wire_seq,
Expand Down
53 changes: 52 additions & 1 deletion crates/caligo-bridge/src/qq_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,13 @@ impl crate::host_adapter::HostAdapter for QqOwnerAdapter {
&& value.get("mid").and_then(|v| v.as_str()) == Some(&request_id)
{
Ok(HostOpResult::SendFired { mid: request_id })
} else if value.get("err").and_then(|v| v.as_str()).is_some() {
} else if let Some(error) = value.get("err").and_then(|v| v.as_str()) {
let label = error
.chars()
.filter(|c| c.is_ascii_alphanumeric() || *c == '_')
.take(64)
.collect::<String>();
append_stage_simple("image_send_error", true, &format!("error={label}"));
Err(HostError::Native { code: 3 })
} else {
Err(HostError::EnvInvalid)
Expand Down Expand Up @@ -1308,6 +1314,47 @@ impl crate::host_adapter::HostAdapter for QqOwnerAdapter {
Err(_) => Err(HostError::EnvInvalid),
}
}
HostOp::SendRich {
request_id,
wire_seq,
timeout_ms,
peer_uin,
chat_type,
segments,
} => {
if !self.voice_profile {
return Err(HostError::NoProvenRoute);
}
let script = crate::qq_v8::build_rich_send_js(
chat_type,
&self.account,
&peer_uin,
&request_id,
wire_seq,
timeout_ms,
&segments,
)
.ok_or(HostError::Native { code: 3 })?;
match crate::qq_v8::run_fixed_query_script(&script) {
Ok(out) => {
if let Ok(v) = serde_json::from_str::<serde_json::Value>(&out) {
if v.get("fired").and_then(|x| x.as_bool()) == Some(true)
&& v.get("mid").and_then(|x| x.as_str()) == Some(&request_id)
{
return Ok(HostOpResult::SendFired { mid: request_id });
}
if v.get("err").and_then(|x| x.as_str()).is_some() {
return Err(HostError::Native { code: 3 });
}
}
Err(HostError::EnvInvalid)
}
Err(crate::qq_v8::V8Error::NoCurrentContext) => {
Err(HostError::NoCurrentContext)
}
Err(_) => Err(HostError::EnvInvalid),
}
}
}
}

Expand All @@ -1329,6 +1376,10 @@ impl crate::host_adapter::HostAdapter for QqOwnerAdapter {

fn supports_image(&self, chat_type: u32) -> bool { self.voice_profile && matches!(chat_type,1|2) }

fn supports_reply(&self, chat_type: u32) -> bool { self.voice_profile && matches!(chat_type,1|2) }

fn supports_mention(&self, chat_type: u32) -> bool { self.voice_profile && chat_type == 2 }

fn supports_group_voice(&self) -> bool {
self.voice_profile
}
Expand Down
41 changes: 36 additions & 5 deletions crates/caligo-bridge/src/qq_image_send.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function (args) {
const deadline = Date.now() + args.timeoutMs;
let cookie, peerUid, element, image;
try {
if (typeof process.getBuiltinModule !== 'function')
return failure('builtin_module_unavailable');
if (!R.ms || typeof R.ms.getRichMediaFilePathForGuild !== 'function' ||
typeof R.ms.sendMsg !== 'function')
return failure('native_image_api_unavailable');
const fs = process.getBuiltinModule('node:fs');
const path = process.getBuiltinModule('node:path');
const crypto = process.getBuiltinModule('node:crypto');
Expand Down Expand Up @@ -61,18 +66,44 @@ function (args) {
const sha256 = crypto.createHash('sha256').update(bytes).digest('hex');
image = {size:bytes.length, md5, width:args.width, height:args.height, picType:1000};
const name = md5 + '.png';
const dest = R.ms.getRichMediaFilePathForGuild({
const rawDest = R.ms.getRichMediaFilePathForGuild({
md5HexStr:md5, fileName:name, elementType:2, elementSubType:0,
thumbSize:0, needCreate:true, downloadType:1, file_uuid:''
});
const windows = process.platform === 'win32';
const samePath = (left, right) => windows ? left.toLowerCase() === right.toLowerCase() : left === right;
if (typeof dest !== 'string' || !path.isAbsolute(dest) || dest !== path.normalize(dest) ||
(windows && !/^[a-zA-Z]:[\\/]/.test(dest)) || !samePath(path.basename(dest), name))
return failure('invalid_image_storage_path');
let rawPath = rawDest;
if (rawDest && typeof rawDest === 'object') {
const keys = ['filePath', 'path', 'file_path', 'filepath'];
for (let i = 0; i < keys.length; i++) {
if (typeof rawDest[keys[i]] === 'string') { rawPath = rawDest[keys[i]]; break; }
}
}
if (typeof rawPath !== 'string') {
const type = rawDest === null ? 'null' : typeof rawDest;
let shape = 'none';
if (rawDest && typeof rawDest === 'object') {
const names = Object.keys(rawDest).slice(0, 16);
shape = ['filePath', 'path', 'file_path', 'filepath'].find(k => names.indexOf(k) >= 0) || 'other';
}
return failure('invalid_image_storage_type_' + type + '_' + shape);
}
let dest = path.normalize(rawPath);
if (!path.isAbsolute(dest) || (windows && !/^[a-zA-Z]:[\\/]/.test(dest)))
return failure('invalid_image_storage_path_absolute');
if (!samePath(path.basename(dest), name)) {
const base = path.basename(dest).toLowerCase();
const ext = path.extname(base);
return failure('invalid_image_storage_basename_' +
(base.startsWith(md5) ? 'md5' : 'other') + '_' + (ext === '.png' ? 'png' : 'other'));
}
const parent = path.dirname(dest);
fs.mkdirSync(parent, {recursive:true});
if (!samePath(fs.realpathSync(parent), parent)) return failure('invalid_image_storage_path');
const realParent = fs.realpathSync(parent);
if (typeof realParent !== 'string' || !path.isAbsolute(realParent) ||
(windows && !/^[a-zA-Z]:[\\/]/.test(realParent)))
return failure('invalid_image_storage_parent');
dest = path.join(realParent, name);
// Create exclusively. A preexisting cache entry can only be reused when
// its bytes match, and files handed to QQ stay owned by its cache.
try {
Expand Down
Loading