mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-26 23:27:22 +00:00
27 lines
710 B
Go
27 lines
710 B
Go
package service
|
|
|
|
import "github.com/tidwall/gjson"
|
|
|
|
// HasCompactionTriggerInInput detects an input item with
|
|
// type="compaction_trigger". The handler combines this body signal with the
|
|
// request path, stream flag, and Codex beta feature header to distinguish the
|
|
// native remote compaction v2 wire from the legacy /responses/compact bridge.
|
|
func HasCompactionTriggerInInput(body []byte) bool {
|
|
if len(body) == 0 {
|
|
return false
|
|
}
|
|
input := gjson.GetBytes(body, "input")
|
|
if !input.IsArray() {
|
|
return false
|
|
}
|
|
found := false
|
|
input.ForEach(func(_, item gjson.Result) bool {
|
|
if item.Get("type").String() == "compaction_trigger" {
|
|
found = true
|
|
return false
|
|
}
|
|
return true
|
|
})
|
|
return found
|
|
}
|