feat: harden loose-offline sync for user JWT, schema, and console ops

Enable Binding-scoped agent push/pull, empty-table schema ensure, SyncPage inspect/drop-table, default module import, and agent-bound publish docs from the 宇恒联调意见.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-08-05 09:47:35 +08:00
parent 76cdcd760e
commit b04b180d30
59 changed files with 4762 additions and 308 deletions

View File

@@ -0,0 +1,51 @@
package dbsync
import (
"errors"
"fmt"
"strings"
)
// RetryableError 上游 IO / remote 暂不可达agent 可稍后重试(不换 UUID
type RetryableError struct {
Msg string
}
func (e *RetryableError) Error() string {
if e == nil {
return "retryable error"
}
return e.Msg
}
func Retryable(msg string) error {
return &RetryableError{Msg: msg}
}
func Retryablef(format string, args ...any) error {
return &RetryableError{Msg: fmt.Sprintf(format, args...)}
}
func IsRetryable(err error) bool {
var r *RetryableError
return errors.As(err, &r)
}
func wrapOpenRemote(err error) error {
if err == nil {
return nil
}
msg := err.Error()
lower := strings.ToLower(msg)
if strings.Contains(lower, "open remote") ||
strings.Contains(lower, "unable to open") ||
strings.Contains(lower, "no such file") ||
strings.Contains(lower, "locked") ||
strings.Contains(lower, "busy") ||
strings.Contains(lower, "connection refused") ||
strings.Contains(lower, "timeout") ||
strings.Contains(lower, "i/o") {
return Retryablef("open remote: %v", err)
}
return Retryablef("open remote: %v", err)
}