Files
weichenandCursor db76a28689 feat(mineru): chunk Agent parse by page_range past 20-page cap
The free Agent lightweight API rejects files over 20 pages (-30003)
and the precision token is expired, so a real 28-page PDF could not
parse at all. On -30003, parse in 20-page windows and renumber chunk
anchors to global pages; report engine mode agent_chunked.

Also log skipped assets in ResolveMaterials and return a bool from
EnqueueAsync so parse_state is only set when a job is enqueued.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-21 10:11:08 +00:00

30 lines
732 B
Go

package mineru_test
import (
"strings"
"testing"
"chat-agent-system/internal/mineru"
)
func TestBumpPageAnchors(t *testing.T) {
in := "<!-- page 1 -->\nA\n<!-- page 2 -->\nB\n"
out := mineru.BumpPageAnchors(in, 20)
if !strings.Contains(out, "<!-- page 21 -->") || !strings.Contains(out, "<!-- page 22 -->") {
t.Fatalf("out=%s", out)
}
}
func TestIsPageLimitError(t *testing.T) {
if !mineru.IsPageLimitError(errString("-30003 file page count exceeds API limit (20 pages)")) {
t.Fatal("should detect page limit")
}
if mineru.IsPageLimitError(errString("A0211 token expired")) {
t.Fatal("must not treat token error as page limit")
}
}
type errString string
func (e errString) Error() string { return string(e) }