diff --git a/pkg/commands/runtime.go b/pkg/commands/runtime.go new file mode 100644 index 000000000..dcc8cb8d7 --- /dev/null +++ b/pkg/commands/runtime.go @@ -0,0 +1,21 @@ +package commands + +import ( + "github.com/sipeed/picoclaw/pkg/config" + "github.com/sipeed/picoclaw/pkg/session" +) + +type SessionOps interface { + ResolveActive(scopeKey string) (string, error) + StartNew(scopeKey string) (string, error) + List(scopeKey string) ([]session.SessionMeta, error) + Resume(scopeKey string, index int) (string, error) + Prune(scopeKey string, limit int) ([]string, error) +} + +type Runtime interface { + Channel() string + ScopeKey() string + SessionOps() SessionOps + Config() *config.Config +} diff --git a/pkg/commands/runtime_test.go b/pkg/commands/runtime_test.go new file mode 100644 index 000000000..0dfa0a04e --- /dev/null +++ b/pkg/commands/runtime_test.go @@ -0,0 +1,53 @@ +package commands + +import ( + "testing" + + "github.com/sipeed/picoclaw/pkg/config" + "github.com/sipeed/picoclaw/pkg/session" +) + +type fakeSessionOps struct{} + +func (f *fakeSessionOps) ResolveActive(scopeKey string) (string, error) { + return "", nil +} + +func (f *fakeSessionOps) StartNew(scopeKey string) (string, error) { + return "", nil +} + +func (f *fakeSessionOps) List(scopeKey string) ([]session.SessionMeta, error) { + return nil, nil +} + +func (f *fakeSessionOps) Resume(scopeKey string, index int) (string, error) { + return "", nil +} + +func (f *fakeSessionOps) Prune(scopeKey string, limit int) ([]string, error) { + return nil, nil +} + +type fakeRuntime struct{} + +func (f *fakeRuntime) Channel() string { + return "" +} + +func (f *fakeRuntime) ScopeKey() string { + return "" +} + +func (f *fakeRuntime) SessionOps() SessionOps { + return &fakeSessionOps{} +} + +func (f *fakeRuntime) Config() *config.Config { + return &config.Config{} +} + +func TestRuntimeContracts_MinimalSessionOps(t *testing.T) { + var _ SessionOps = (*fakeSessionOps)(nil) + var _ Runtime = (*fakeRuntime)(nil) +}