chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package hitl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"academy/internal/types"
|
||||
)
|
||||
|
||||
type delegationKey struct{}
|
||||
|
||||
// Delegation is installed by the worker, never from model arguments. Register
|
||||
// durably associates a prompt with the current run before it can be answered.
|
||||
type Delegation struct {
|
||||
Register func(context.Context, *types.AgentPrompt) error
|
||||
Check func(context.Context) error
|
||||
}
|
||||
|
||||
// WithDelegation attaches child prompt ownership checks to the execution context.
|
||||
func WithDelegation(ctx context.Context, d Delegation) context.Context {
|
||||
return context.WithValue(ctx, delegationKey{}, d)
|
||||
}
|
||||
|
||||
// CheckDelegation rejects canceled or stale child executions before prompt handling.
|
||||
func CheckDelegation(ctx context.Context) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if d, ok := ctx.Value(delegationKey{}).(Delegation); ok && d.Check != nil {
|
||||
return d.Check(ctx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user