调价后的新价格写入报价单;多段段前的货物带到各段,协同群不再把体积里的星号吃掉。海运字段齐了先核对再查价。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,8 +15,17 @@ function pickReplyReqId({ fromCaller, fromChat, lastAny }) {
|
||||
return String(lastAny || "").trim();
|
||||
}
|
||||
|
||||
// 含星号的尺寸或箱量。已在行内代码里的整段跳过,避免套两层。
|
||||
const STAR_TOKEN = /`[^`]*`|([A-Za-z0-9.]+(?:\s*\*\s*[A-Za-z0-9.]+)+)/g;
|
||||
|
||||
function showLiteralAsterisks(text) {
|
||||
// 企微 markdown 会吃掉星号:1.1*2.1*2.1 显示成 1.12.12.1。
|
||||
// 放进行内代码后,群里仍是星号。智能体若已经套过,这里不再套第二层。
|
||||
return String(text || "").replace(STAR_TOKEN, (full, token) => (token ? "`" + token + "`" : full));
|
||||
}
|
||||
|
||||
function buildGroupMessageFrame({ chatId, content, callbackReqId, reqId }) {
|
||||
const text = String(content || "");
|
||||
const text = showLiteralAsterisks(String(content || ""));
|
||||
const markdown = { content: text };
|
||||
if (callbackReqId) {
|
||||
return {
|
||||
@@ -42,4 +51,4 @@ function buildGroupMessageFrame({ chatId, content, callbackReqId, reqId }) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { buildGroupMessageFrame, pickReplyReqId };
|
||||
module.exports = { buildGroupMessageFrame, pickReplyReqId, showLiteralAsterisks };
|
||||
|
||||
@@ -24,6 +24,21 @@ test("group reply never uses stream", () => {
|
||||
assert.equal(proactive.body.markdown.feedback, undefined);
|
||||
});
|
||||
|
||||
test("dimension asterisks stay visible in group markdown", () => {
|
||||
const frame = buildGroupMessageFrame({
|
||||
chatId: "wr_1",
|
||||
content: "体积(CBM)(必填):1.1*2.1*2.1",
|
||||
callbackReqId: "",
|
||||
});
|
||||
assert.equal(frame.body.markdown.content, "体积(CBM)(必填):`1.1*2.1*2.1`");
|
||||
const again = buildGroupMessageFrame({
|
||||
chatId: "wr_1",
|
||||
content: frame.body.markdown.content,
|
||||
callbackReqId: "",
|
||||
});
|
||||
assert.equal(again.body.markdown.content, "体积(CBM)(必填):`1.1*2.1*2.1`");
|
||||
});
|
||||
|
||||
test("reply req id falls back to last inbound when chat map misses", () => {
|
||||
assert.equal(pickReplyReqId({ fromCaller: "cb_1", fromChat: "old", lastAny: "any" }), "cb_1");
|
||||
assert.equal(pickReplyReqId({ fromCaller: "", fromChat: "chat_cb", lastAny: "any" }), "chat_cb");
|
||||
|
||||
Reference in New Issue
Block a user