feat: implement runtime service and types for application integration
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
package runtime
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
runtimeapp "cs-agent/internal/ai/runtime/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
app *runtimeapp.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewService() *Service {
|
||||||
|
return &Service{
|
||||||
|
app: runtimeapp.NewService(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) Run(ctx context.Context, req Request) (*Summary, error) {
|
||||||
|
if s == nil || s.app == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return s.app.Run(ctx, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) Resume(ctx context.Context, req ResumeRequest) (*Summary, error) {
|
||||||
|
if s == nil || s.app == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return s.app.Resume(ctx, req)
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package runtime
|
||||||
|
|
||||||
|
import runtimeapp "cs-agent/internal/ai/runtime/app"
|
||||||
|
|
||||||
|
// TODO 为什么要定义类型别名?
|
||||||
|
type Request = runtimeapp.Request
|
||||||
|
type ResumeRequest = runtimeapp.ResumeRequest
|
||||||
|
type InterruptContextSummary = runtimeapp.InterruptContextSummary
|
||||||
|
type Summary = runtimeapp.Summary
|
||||||
@@ -3,19 +3,19 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
runtimeapp "cs-agent/internal/ai/runtime/app"
|
applicationruntime "cs-agent/internal/ai/application/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Service = newService()
|
var Service = newService()
|
||||||
|
|
||||||
func newService() *service {
|
func newService() *service {
|
||||||
return &service{
|
return &service{
|
||||||
app: runtimeapp.NewService(),
|
app: applicationruntime.NewService(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
app *runtimeapp.Service
|
app *applicationruntime.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *service) Run(ctx context.Context, req Request) (*Summary, error) {
|
func (s *service) Run(ctx context.Context, req Request) (*Summary, error) {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
import runtimeapp "cs-agent/internal/ai/runtime/app"
|
import applicationruntime "cs-agent/internal/ai/application/runtime"
|
||||||
|
|
||||||
// TODO 这里为什么再设置一下类型别名,不能直接在外部使用 runtimeapp.Request 之类的类型呢?
|
type Request = applicationruntime.Request
|
||||||
type Request = runtimeapp.Request
|
type ResumeRequest = applicationruntime.ResumeRequest
|
||||||
type ResumeRequest = runtimeapp.ResumeRequest
|
type InterruptContextSummary = applicationruntime.InterruptContextSummary
|
||||||
type InterruptContextSummary = runtimeapp.InterruptContextSummary
|
type Summary = applicationruntime.Summary
|
||||||
type Summary = runtimeapp.Summary
|
|
||||||
|
|||||||
Reference in New Issue
Block a user