feat: publish sanitized custom.97 source

This commit is contained in:
cneicy committed 2026-10-27 20:43:39 +08:00
1 parent 8e6ed0317b
commit 86c0276156
1022 files changed
+69903 -19207

No files matched your search

+30 -6
View File
@@ -131,6 +131,11 @@ type TaskPrivateData struct {
PluginState json.RawMessage `json:"plugin_state,omitempty"`
// PollFailures counts consecutive unrecognized or transient poll outcomes.
PollFailures int `json:"poll_failures,omitempty"`
// ResultDiscarded marks an immediate terminal result whose submit route
// declared retainResult: false. The upstream snapshot was never written
// and every retrieval surface treats the task as not found. The zero
// value keeps historical rows retained and retrievable.
ResultDiscarded bool `json:"result_discarded,omitempty"`
}
type TaskExecutionSnapshot struct {
@@ -166,6 +171,12 @@ type TaskBillingContext struct {
TieredSnapshot *billingexpr.BillingSnapshot `json:"tiered_snapshot,omitempty"`
}
// ResultRetrievable reports whether retrieval surfaces (native query routes,
// protocol retrieve endpoints, artifact projection) may serve this task.
func (t *Task) ResultRetrievable() bool {
return !t.PrivateData.ResultDiscarded
}
// GetUpstreamTaskID 获取上游真实 task ID(用于与 provider 通信)
// 旧数据没有 UpstreamTaskID 时,TaskID 本身就是上游 ID
func (t *Task) GetUpstreamTaskID() string {
@@ -202,7 +213,8 @@ func (p TaskPrivateData) Value() (driver.Value, error) {
if p.Key == "" && p.UpstreamTaskID == "" && p.ResultURL == "" &&
p.Execution == nil && p.BillingSource == "" && p.SubscriptionId == 0 &&
p.TokenId == 0 && p.NodeName == "" && p.BillingContext == nil &&
!p.ResponsesBackground && len(p.PluginState) == 0 && p.PollFailures == 0 {
!p.ResponsesBackground && len(p.PluginState) == 0 && p.PollFailures == 0 &&
!p.ResultDiscarded {
return nil, nil
}
// 同 Properties.Value:string 避免 PG simple protocol 的 bytea 编码。
@@ -230,8 +242,11 @@ func InitTask(platform constant.TaskPlatform, relayInfo *commonRelay.RelayInfo)
properties := Properties{}
privateData := TaskPrivateData{}
if relayInfo != nil && relayInfo.ChannelMeta != nil {
// A New API channel may rotate between several gateway tokens, so the
// task keeps the key that submitted it and polls with the same identity.
if relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeGemini ||
relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeVertexAi {
relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeVertexAi ||
relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeNewAPI {
privateData.Key = relayInfo.ChannelMeta.ApiKey
}
if relayInfo.UpstreamModelName != "" {
@@ -293,7 +308,9 @@ func TaskGetAllUserTask(userId int, startIdx int, num int, queryParams SyncTaskQ
}
// 获取数据
err = query.Omit("channel_id").Order("id desc").Limit(num).Offset(startIdx).Find(&tasks).Error
// Task lists never render the persisted upstream snapshot; the dashboard
// loads media through the artifacts endpoint instead.
err = query.Omit("channel_id", "data").Order("id desc").Limit(num).Offset(startIdx).Find(&tasks).Error
if err != nil {
return nil
}
@@ -338,7 +355,7 @@ func TaskGetAllTasks(startIdx int, num int, queryParams SyncTaskQueryParams) []*
}
// 获取数据
err = query.Order("id desc").Limit(num).Offset(startIdx).Find(&tasks).Error
err = query.Omit("data").Order("id desc").Limit(num).Offset(startIdx).Find(&tasks).Error
if err != nil {
return nil
}
@@ -469,8 +486,15 @@ func (Task *Task) Insert() error {
return Task.InsertWithContext(context.Background())
}
func (Task *Task) InsertWithContext(ctx context.Context) error {
return DB.WithContext(ctx).Create(Task).Error
// InsertWithContext creates the row. omitColumns are left out of the INSERT
// (for example "data" when the submit route discards the upstream snapshot)
// while the in-memory task keeps its values for presentation.
func (Task *Task) InsertWithContext(ctx context.Context, omitColumns ...string) error {
tx := DB.WithContext(ctx)
if len(omitColumns) > 0 {
tx = tx.Omit(omitColumns...)
}
return tx.Create(Task).Error
}
type taskSnapshot struct {