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>
30 lines
732 B
Go
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) }
|