feat(controlplane): expose resource history so edits can be reviewed and rolled back

resource_history has carried a row per change since the control plane landed
(value, version, actor, source, request ID, both versions, timestamp), but
nothing could read it. The audit trail existed and was invisible, and the PRD's
"shows failed changes and can correct or roll them back" had nothing to stand
on.

Restoring is deliberately not a command of its own. A revision carries the
value it held, so putting one back is an ordinary replace against the version
currently stored: the restore lands in the same history as every other edit,
under the same optimistic concurrency, instead of rewriting the past.

The revision value crosses the HTTP boundary as raw JSON rather than the base64
a proto bytes field renders as, because the dashboard sends it straight back as
the replace payload.

ResourceStore is exported from the controlplane package and the State Store
composition asserts against it, replacing the inline anonymous interface that
had started to drift from the real requirement.
This commit is contained in:
sam committed 2026-09-21 09:11:17 +10:00
1 parent 2311529def
commit 44f8e19f0d
18 files changed
+674 -51

No files matched your search

+1 -4
View File
@@ -96,10 +96,7 @@ func RunStateStore(ctx context.Context, options StateStoreOptions) error {
if err := identityStore.BootstrapIdentities(ctx, legacyNames); err != nil {
return fmt.Errorf("bootstrap identities: %w", err)
}
resources, ok := b.st.(interface {
Resource(context.Context, string) (store.Resource, error)
PutResource(context.Context, store.ResourceWrite) (store.Resource, error)
})
resources, ok := b.st.(controlplane.ResourceStore)
if !ok {
return fmt.Errorf("state store does not support control-plane resources")
}
+36 -3
View File
@@ -21,19 +21,27 @@ var (
ErrUnavailable = errors.New("control-plane unavailable")
)
type resourceStore interface {
// ResourceStore is the persistence the control plane requires. The composition
// root asserts the State Store against it, so this is the single definition of
// what a control-plane backing store must offer.
type ResourceStore interface {
Resource(context.Context, string) (store.Resource, error)
ResourceHistory(context.Context, string, int) ([]store.Resource, error)
PutResource(context.Context, store.ResourceWrite) (store.Resource, error)
}
// defaultHistoryLimit caps an unbounded request. A settings resource edited
// daily for a year still fits, and the dashboard pages rather than streams.
const defaultHistoryLimit = 200
type Server struct {
pb.UnimplementedControlPlaneServiceServer
store resourceStore
store ResourceStore
definitions map[string]Definition
ordered []Definition
}
func NewServer(resources resourceStore) *Server {
func NewServer(resources ResourceStore) *Server {
definitions := builtinDefinitions()
byKind := make(map[string]Definition, len(definitions))
for _, definition := range definitions {
@@ -62,6 +70,31 @@ func (s *Server) Query(ctx context.Context, request *pb.QueryRequest) (*pb.Query
return &pb.QueryResponse{Resource: resourceProto(resource)}, nil
}
// History answers a resource's audit trail. The value of each revision comes
// back with it: restoring one is an ordinary replace of that value, so no
// rollback command of its own is needed.
func (s *Server) History(ctx context.Context, request *pb.HistoryRequest) (*pb.HistoryResponse, error) {
if _, ok := s.definitions[request.GetKind()]; !ok {
return nil, status.Error(codes.NotFound, "resource not found")
}
limit := int(request.GetLimit())
if limit <= 0 || limit > defaultHistoryLimit {
limit = defaultHistoryLimit
}
revisions, err := s.store.ResourceHistory(ctx, request.Kind, limit)
if err != nil {
return nil, mapError(err)
}
out := make([]*pb.Revision, 0, len(revisions))
for _, revision := range revisions {
out = append(out, &pb.Revision{
Version: revision.Version, ValueJson: revision.Value, Actor: revision.Actor,
Source: revision.Source, RequestId: revision.RequestID, At: timestamp(revision.At),
})
}
return &pb.HistoryResponse{Revisions: out}, nil
}
func (s *Server) Command(ctx context.Context, request *pb.CommandRequest) (*pb.CommandResponse, error) {
definition, ok := s.definitions[request.GetKind()]
if !ok || request.GetCommand() != "replace" {
@@ -6,6 +6,9 @@ import (
"testing"
"time"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/samcharles93/archie-core/internal/config"
pb "github.com/samcharles93/archie-core/internal/contracts/controlplane/v1"
"github.com/samcharles93/archie-core/internal/domain/agent"
@@ -200,3 +203,44 @@ func TestProviderSeedKeepsReferencesAndNeverResolvedSecrets(t *testing.T) {
t.Fatalf("provider resource = %s", encoded)
}
}
func TestHistoryCarriesEveryRevisionWithItsAudit(t *testing.T) {
t.Parallel()
resources := store.OpenTest(t)
defer resources.Close()
server := NewServer(resources)
if _, err := server.ImportConfig(t.Context(), config.Config{}); err != nil {
t.Fatal(err)
}
seeded, err := server.Query(t.Context(), &pb.QueryRequest{Kind: WorkflowExecutionSettingsKind})
if err != nil {
t.Fatal(err)
}
if _, err := server.Command(t.Context(), &pb.CommandRequest{
Kind: WorkflowExecutionSettingsKind, Command: "replace",
ValueJson: []byte(`{"max_model_tool_steps":40,"max_runtime_seconds":600,"max_consecutive_gate_failures":2}`),
ExpectedVersion: seeded.Resource.Version, Actor: "operator", Source: "archie-ui", RequestId: "edit-1",
}); err != nil {
t.Fatal(err)
}
history, err := server.History(t.Context(), &pb.HistoryRequest{Kind: WorkflowExecutionSettingsKind})
if err != nil {
t.Fatal(err)
}
if len(history.Revisions) != 2 {
t.Fatalf("revisions = %d, want the seed and the edit", len(history.Revisions))
}
newest := history.Revisions[0]
if newest.Actor != "operator" || newest.Source != "archie-ui" || newest.RequestId != "edit-1" {
t.Fatalf("newest revision audit = %+v, want the dashboard edit", newest)
}
// The value rides along so a restore is an ordinary replace of it.
if len(history.Revisions[1].ValueJson) == 0 {
t.Fatal("older revision carries no value; nothing to restore from")
}
if _, err := server.History(t.Context(), &pb.HistoryRequest{Kind: "not-a-resource"}); status.Code(err) != codes.NotFound {
t.Fatalf("history for an unknown kind = %v, want NotFound", err)
}
}
@@ -22,6 +22,10 @@ func (c *runtimeConfigClient) Query(_ context.Context, request *pb.QueryRequest,
return &pb.QueryResponse{Resource: &pb.Resource{Kind: request.Kind, Version: 2, ValueJson: value}}, err
}
func (*runtimeConfigClient) History(context.Context, *pb.HistoryRequest, ...grpc.CallOption) (*pb.HistoryResponse, error) {
panic("unexpected History")
}
func (*runtimeConfigClient) Command(context.Context, *pb.CommandRequest, ...grpc.CallOption) (*pb.CommandResponse, error) {
panic("unexpected Command")
}
@@ -363,6 +363,190 @@ func (x *QueryResponse) GetResource() *Resource {
return nil
}
// Revision is one entry of a resource's audit trail: the value that version
// held, and who changed it from where.
type Revision struct {
state protoimpl.MessageState `protogen:"open.v1"`
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
ValueJson []byte `protobuf:"bytes,2,opt,name=value_json,json=valueJson,proto3" json:"value_json,omitempty"`
Actor string `protobuf:"bytes,3,opt,name=actor,proto3" json:"actor,omitempty"`
Source string `protobuf:"bytes,4,opt,name=source,proto3" json:"source,omitempty"`
RequestId string `protobuf:"bytes,5,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
At *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=at,proto3" json:"at,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Revision) Reset() {
*x = Revision{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Revision) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Revision) ProtoMessage() {}
func (x *Revision) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Revision.ProtoReflect.Descriptor instead.
func (*Revision) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{6}
}
func (x *Revision) GetVersion() int64 {
if x != nil {
return x.Version
}
return 0
}
func (x *Revision) GetValueJson() []byte {
if x != nil {
return x.ValueJson
}
return nil
}
func (x *Revision) GetActor() string {
if x != nil {
return x.Actor
}
return ""
}
func (x *Revision) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
func (x *Revision) GetRequestId() string {
if x != nil {
return x.RequestId
}
return ""
}
func (x *Revision) GetAt() *timestamppb.Timestamp {
if x != nil {
return x.At
}
return nil
}
type HistoryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
// Limit caps the revisions returned, newest first. Zero means the server's
// own default.
Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HistoryRequest) Reset() {
*x = HistoryRequest{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HistoryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HistoryRequest) ProtoMessage() {}
func (x *HistoryRequest) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HistoryRequest.ProtoReflect.Descriptor instead.
func (*HistoryRequest) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{7}
}
func (x *HistoryRequest) GetKind() string {
if x != nil {
return x.Kind
}
return ""
}
func (x *HistoryRequest) GetLimit() int32 {
if x != nil {
return x.Limit
}
return 0
}
type HistoryResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Revisions []*Revision `protobuf:"bytes,1,rep,name=revisions,proto3" json:"revisions,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HistoryResponse) Reset() {
*x = HistoryResponse{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HistoryResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HistoryResponse) ProtoMessage() {}
func (x *HistoryResponse) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HistoryResponse.ProtoReflect.Descriptor instead.
func (*HistoryResponse) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{8}
}
func (x *HistoryResponse) GetRevisions() []*Revision {
if x != nil {
return x.Revisions
}
return nil
}
type CommandRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"`
@@ -380,7 +564,7 @@ type CommandRequest struct {
func (x *CommandRequest) Reset() {
*x = CommandRequest{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[6]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -392,7 +576,7 @@ func (x *CommandRequest) String() string {
func (*CommandRequest) ProtoMessage() {}
func (x *CommandRequest) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[6]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -405,7 +589,7 @@ func (x *CommandRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CommandRequest.ProtoReflect.Descriptor instead.
func (*CommandRequest) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{6}
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{9}
}
func (x *CommandRequest) GetKind() string {
@@ -466,7 +650,7 @@ type CommandResponse struct {
func (x *CommandResponse) Reset() {
*x = CommandResponse{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[7]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -478,7 +662,7 @@ func (x *CommandResponse) String() string {
func (*CommandResponse) ProtoMessage() {}
func (x *CommandResponse) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[7]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -491,7 +675,7 @@ func (x *CommandResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CommandResponse.ProtoReflect.Descriptor instead.
func (*CommandResponse) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{7}
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{10}
}
func (x *CommandResponse) GetResource() *Resource {
@@ -511,7 +695,7 @@ type WatchRequest struct {
func (x *WatchRequest) Reset() {
*x = WatchRequest{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[8]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -523,7 +707,7 @@ func (x *WatchRequest) String() string {
func (*WatchRequest) ProtoMessage() {}
func (x *WatchRequest) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[8]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -536,7 +720,7 @@ func (x *WatchRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use WatchRequest.ProtoReflect.Descriptor instead.
func (*WatchRequest) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{8}
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{11}
}
func (x *WatchRequest) GetKind() string {
@@ -563,7 +747,7 @@ type WatchResponse struct {
func (x *WatchResponse) Reset() {
*x = WatchResponse{}
mi := &file_controlplane_v1_controlplane_proto_msgTypes[9]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -575,7 +759,7 @@ func (x *WatchResponse) String() string {
func (*WatchResponse) ProtoMessage() {}
func (x *WatchResponse) ProtoReflect() protoreflect.Message {
mi := &file_controlplane_v1_controlplane_proto_msgTypes[9]
mi := &file_controlplane_v1_controlplane_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -588,7 +772,7 @@ func (x *WatchResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use WatchResponse.ProtoReflect.Descriptor instead.
func (*WatchResponse) Descriptor() ([]byte, []int) {
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{9}
return file_controlplane_v1_controlplane_proto_rawDescGZIP(), []int{12}
}
func (x *WatchResponse) GetResource() *Resource {
@@ -634,7 +818,21 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
"\fQueryRequest\x12\x12\n" +
"\x04kind\x18\x01 \x01(\tR\x04kind\"F\n" +
"\rQueryResponse\x125\n" +
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\"\xd5\x01\n" +
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\"\xbc\x01\n" +
"\bRevision\x12\x18\n" +
"\aversion\x18\x01 \x01(\x03R\aversion\x12\x1d\n" +
"\n" +
"value_json\x18\x02 \x01(\fR\tvalueJson\x12\x14\n" +
"\x05actor\x18\x03 \x01(\tR\x05actor\x12\x16\n" +
"\x06source\x18\x04 \x01(\tR\x06source\x12\x1d\n" +
"\n" +
"request_id\x18\x05 \x01(\tR\trequestId\x12*\n" +
"\x02at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x02at\":\n" +
"\x0eHistoryRequest\x12\x12\n" +
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x14\n" +
"\x05limit\x18\x02 \x01(\x05R\x05limit\"J\n" +
"\x0fHistoryResponse\x127\n" +
"\trevisions\x18\x01 \x03(\v2\x19.controlplane.v1.RevisionR\trevisions\"\xd5\x01\n" +
"\x0eCommandRequest\x12\x12\n" +
"\x04kind\x18\x01 \x01(\tR\x04kind\x12\x18\n" +
"\acommand\x18\x02 \x01(\tR\acommand\x12\x1d\n" +
@@ -652,10 +850,11 @@ const file_controlplane_v1_controlplane_proto_rawDesc = "" +
"\rafter_version\x18\x02 \x01(\x03R\fafterVersion\"\\\n" +
"\rWatchResponse\x125\n" +
"\bresource\x18\x01 \x01(\v2\x19.controlplane.v1.ResourceR\bresource\x12\x14\n" +
"\x05error\x18\x02 \x01(\tR\x05error2\xc3\x02\n" +
"\x05error\x18\x02 \x01(\tR\x05error2\x91\x03\n" +
"\x13ControlPlaneService\x12L\n" +
"\aCatalog\x12\x1f.controlplane.v1.CatalogRequest\x1a .controlplane.v1.CatalogResponse\x12F\n" +
"\x05Query\x12\x1d.controlplane.v1.QueryRequest\x1a\x1e.controlplane.v1.QueryResponse\x12L\n" +
"\aHistory\x12\x1f.controlplane.v1.HistoryRequest\x1a .controlplane.v1.HistoryResponse\x12L\n" +
"\aCommand\x12\x1f.controlplane.v1.CommandRequest\x1a .controlplane.v1.CommandResponse\x12H\n" +
"\x05Watch\x12\x1d.controlplane.v1.WatchRequest\x1a\x1e.controlplane.v1.WatchResponse0\x01B\xdc\x01\n" +
"\x13com.controlplane.v1B\x11ControlplaneProtoP\x01ZUgithub.com/samcharles93/archie-core/internal/contracts/controlplane/v1;controlplanev1\xa2\x02\x03CXX\xaa\x02\x0fControlplane.V1\xca\x02\x0fControlplane\\V1\xe2\x02\x1bControlplane\\V1\\GPBMetadata\xea\x02\x10Controlplane::V1b\x06proto3"
@@ -672,7 +871,7 @@ func file_controlplane_v1_controlplane_proto_rawDescGZIP() []byte {
return file_controlplane_v1_controlplane_proto_rawDescData
}
var file_controlplane_v1_controlplane_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_controlplane_v1_controlplane_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_controlplane_v1_controlplane_proto_goTypes = []any{
(*ResourceDescriptor)(nil), // 0: controlplane.v1.ResourceDescriptor
(*CatalogRequest)(nil), // 1: controlplane.v1.CatalogRequest
@@ -680,31 +879,38 @@ var file_controlplane_v1_controlplane_proto_goTypes = []any{
(*Resource)(nil), // 3: controlplane.v1.Resource
(*QueryRequest)(nil), // 4: controlplane.v1.QueryRequest
(*QueryResponse)(nil), // 5: controlplane.v1.QueryResponse
(*CommandRequest)(nil), // 6: controlplane.v1.CommandRequest
(*CommandResponse)(nil), // 7: controlplane.v1.CommandResponse
(*WatchRequest)(nil), // 8: controlplane.v1.WatchRequest
(*WatchResponse)(nil), // 9: controlplane.v1.WatchResponse
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
(*Revision)(nil), // 6: controlplane.v1.Revision
(*HistoryRequest)(nil), // 7: controlplane.v1.HistoryRequest
(*HistoryResponse)(nil), // 8: controlplane.v1.HistoryResponse
(*CommandRequest)(nil), // 9: controlplane.v1.CommandRequest
(*CommandResponse)(nil), // 10: controlplane.v1.CommandResponse
(*WatchRequest)(nil), // 11: controlplane.v1.WatchRequest
(*WatchResponse)(nil), // 12: controlplane.v1.WatchResponse
(*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp
}
var file_controlplane_v1_controlplane_proto_depIdxs = []int32{
0, // 0: controlplane.v1.CatalogResponse.resources:type_name -> controlplane.v1.ResourceDescriptor
10, // 1: controlplane.v1.Resource.updated_at:type_name -> google.protobuf.Timestamp
13, // 1: controlplane.v1.Resource.updated_at:type_name -> google.protobuf.Timestamp
3, // 2: controlplane.v1.QueryResponse.resource:type_name -> controlplane.v1.Resource
3, // 3: controlplane.v1.CommandResponse.resource:type_name -> controlplane.v1.Resource
3, // 4: controlplane.v1.WatchResponse.resource:type_name -> controlplane.v1.Resource
1, // 5: controlplane.v1.ControlPlaneService.Catalog:input_type -> controlplane.v1.CatalogRequest
4, // 6: controlplane.v1.ControlPlaneService.Query:input_type -> controlplane.v1.QueryRequest
6, // 7: controlplane.v1.ControlPlaneService.Command:input_type -> controlplane.v1.CommandRequest
8, // 8: controlplane.v1.ControlPlaneService.Watch:input_type -> controlplane.v1.WatchRequest
2, // 9: controlplane.v1.ControlPlaneService.Catalog:output_type -> controlplane.v1.CatalogResponse
5, // 10: controlplane.v1.ControlPlaneService.Query:output_type -> controlplane.v1.QueryResponse
7, // 11: controlplane.v1.ControlPlaneService.Command:output_type -> controlplane.v1.CommandResponse
9, // 12: controlplane.v1.ControlPlaneService.Watch:output_type -> controlplane.v1.WatchResponse
9, // [9:13] is the sub-list for method output_type
5, // [5:9] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
13, // 3: controlplane.v1.Revision.at:type_name -> google.protobuf.Timestamp
6, // 4: controlplane.v1.HistoryResponse.revisions:type_name -> controlplane.v1.Revision
3, // 5: controlplane.v1.CommandResponse.resource:type_name -> controlplane.v1.Resource
3, // 6: controlplane.v1.WatchResponse.resource:type_name -> controlplane.v1.Resource
1, // 7: controlplane.v1.ControlPlaneService.Catalog:input_type -> controlplane.v1.CatalogRequest
4, // 8: controlplane.v1.ControlPlaneService.Query:input_type -> controlplane.v1.QueryRequest
7, // 9: controlplane.v1.ControlPlaneService.History:input_type -> controlplane.v1.HistoryRequest
9, // 10: controlplane.v1.ControlPlaneService.Command:input_type -> controlplane.v1.CommandRequest
11, // 11: controlplane.v1.ControlPlaneService.Watch:input_type -> controlplane.v1.WatchRequest
2, // 12: controlplane.v1.ControlPlaneService.Catalog:output_type -> controlplane.v1.CatalogResponse
5, // 13: controlplane.v1.ControlPlaneService.Query:output_type -> controlplane.v1.QueryResponse
8, // 14: controlplane.v1.ControlPlaneService.History:output_type -> controlplane.v1.HistoryResponse
10, // 15: controlplane.v1.ControlPlaneService.Command:output_type -> controlplane.v1.CommandResponse
12, // 16: controlplane.v1.ControlPlaneService.Watch:output_type -> controlplane.v1.WatchResponse
12, // [12:17] is the sub-list for method output_type
7, // [7:12] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_controlplane_v1_controlplane_proto_init() }
@@ -718,7 +924,7 @@ func file_controlplane_v1_controlplane_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_controlplane_v1_controlplane_proto_rawDesc), len(file_controlplane_v1_controlplane_proto_rawDesc)),
NumEnums: 0,
NumMessages: 10,
NumMessages: 13,
NumExtensions: 0,
NumServices: 1,
},
@@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion9
const (
ControlPlaneService_Catalog_FullMethodName = "/controlplane.v1.ControlPlaneService/Catalog"
ControlPlaneService_Query_FullMethodName = "/controlplane.v1.ControlPlaneService/Query"
ControlPlaneService_History_FullMethodName = "/controlplane.v1.ControlPlaneService/History"
ControlPlaneService_Command_FullMethodName = "/controlplane.v1.ControlPlaneService/Command"
ControlPlaneService_Watch_FullMethodName = "/controlplane.v1.ControlPlaneService/Watch"
)
@@ -31,6 +32,7 @@ const (
type ControlPlaneServiceClient interface {
Catalog(ctx context.Context, in *CatalogRequest, opts ...grpc.CallOption) (*CatalogResponse, error)
Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
History(ctx context.Context, in *HistoryRequest, opts ...grpc.CallOption) (*HistoryResponse, error)
Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error)
Watch(ctx context.Context, in *WatchRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WatchResponse], error)
}
@@ -63,6 +65,16 @@ func (c *controlPlaneServiceClient) Query(ctx context.Context, in *QueryRequest,
return out, nil
}
func (c *controlPlaneServiceClient) History(ctx context.Context, in *HistoryRequest, opts ...grpc.CallOption) (*HistoryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(HistoryResponse)
err := c.cc.Invoke(ctx, ControlPlaneService_History_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *controlPlaneServiceClient) Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CommandResponse)
@@ -98,6 +110,7 @@ type ControlPlaneService_WatchClient = grpc.ServerStreamingClient[WatchResponse]
type ControlPlaneServiceServer interface {
Catalog(context.Context, *CatalogRequest) (*CatalogResponse, error)
Query(context.Context, *QueryRequest) (*QueryResponse, error)
History(context.Context, *HistoryRequest) (*HistoryResponse, error)
Command(context.Context, *CommandRequest) (*CommandResponse, error)
Watch(*WatchRequest, grpc.ServerStreamingServer[WatchResponse]) error
mustEmbedUnimplementedControlPlaneServiceServer()
@@ -116,6 +129,9 @@ func (UnimplementedControlPlaneServiceServer) Catalog(context.Context, *CatalogR
func (UnimplementedControlPlaneServiceServer) Query(context.Context, *QueryRequest) (*QueryResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Query not implemented")
}
func (UnimplementedControlPlaneServiceServer) History(context.Context, *HistoryRequest) (*HistoryResponse, error) {
return nil, status.Error(codes.Unimplemented, "method History not implemented")
}
func (UnimplementedControlPlaneServiceServer) Command(context.Context, *CommandRequest) (*CommandResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Command not implemented")
}
@@ -179,6 +195,24 @@ func _ControlPlaneService_Query_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _ControlPlaneService_History_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HistoryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ControlPlaneServiceServer).History(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ControlPlaneService_History_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ControlPlaneServiceServer).History(ctx, req.(*HistoryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _ControlPlaneService_Command_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CommandRequest)
if err := dec(in); err != nil {
@@ -223,6 +257,10 @@ var ControlPlaneService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Query",
Handler: _ControlPlaneService_Query_Handler,
},
{
MethodName: "History",
Handler: _ControlPlaneService_History_Handler,
},
{
MethodName: "Command",
Handler: _ControlPlaneService_Command_Handler,
+23
View File
@@ -58,6 +58,29 @@ func (s *Store) Resource(ctx context.Context, kind string) (Resource, error) {
return r, err
}
// ResourceHistory returns kind's revisions newest first, each carrying the
// audit record written with it. limit caps the rows; zero or less returns
// every revision. An unknown kind has no history, which is not an error.
func (s *Store) ResourceHistory(ctx context.Context, kind string, limit int) ([]Resource, error) {
if limit <= 0 {
limit = -1
}
rows, err := s.db.QueryContext(ctx, `SELECT kind,value,version,actor,source,request_id,expected_version,current_version,at FROM resource_history WHERE kind=? ORDER BY version DESC LIMIT ?`, kind, limit)
if err != nil {
return nil, err
}
defer func() { _ = rows.Close() }()
var history []Resource
for rows.Next() {
var r Resource
if err := rows.Scan(&r.Kind, &r.Value, &r.Version, &r.Actor, &r.Source, &r.RequestID, &r.ExpectedVersion, &r.CurrentVersion, sqliteTime{&r.At}); err != nil {
return nil, err
}
history = append(history, r)
}
return history, rows.Err()
}
func (s *Store) PutResource(ctx context.Context, w ResourceWrite) (_ Resource, retErr error) {
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
+50
View File
@@ -38,3 +38,53 @@ func TestPutResourceDuplicateRequestIsIdempotent(t *testing.T) {
t.Fatalf("duplicate = (%d, %s), want (%d, %s)", second.Version, second.Value, first.Version, first.Value)
}
}
func TestResourceHistoryReturnsEveryRevisionNewestFirst(t *testing.T) {
s := OpenTest(t)
defer s.Close()
ctx := t.Context()
for i, write := range []ResourceWrite{
{Kind: "settings", Value: []byte(`{"v":1}`), Actor: "operator", Source: "archie-ui", RequestID: "r1", ExpectedVersion: 0},
{Kind: "settings", Value: []byte(`{"v":2}`), Actor: "operator", Source: "messaging", RequestID: "r2", ExpectedVersion: 1},
{Kind: "other", Value: []byte(`{"v":9}`), Actor: "operator", Source: "archie-ui", RequestID: "r3", ExpectedVersion: 0},
} {
write.At = time.Now().UTC()
if _, err := s.PutResource(ctx, write); err != nil {
t.Fatalf("write %d: %v", i, err)
}
}
history, err := s.ResourceHistory(ctx, "settings", 10)
if err != nil {
t.Fatal(err)
}
if len(history) != 2 {
t.Fatalf("history = %d revisions, want 2 (other kinds must not leak in)", len(history))
}
if history[0].Version != 2 || string(history[0].Value) != `{"v":2}` || history[0].Source != "messaging" {
t.Fatalf("newest revision = %+v, want version 2 from messaging", history[0])
}
if history[1].Version != 1 || history[1].Actor != "operator" || history[1].At.IsZero() {
t.Fatalf("oldest revision = %+v, want version 1 with its audit intact", history[1])
}
limited, err := s.ResourceHistory(ctx, "settings", 1)
if err != nil {
t.Fatal(err)
}
if len(limited) != 1 || limited[0].Version != 2 {
t.Fatalf("limited history = %+v, want the newest revision alone", limited)
}
}
func TestResourceHistoryForUnknownKindIsEmpty(t *testing.T) {
s := OpenTest(t)
defer s.Close()
history, err := s.ResourceHistory(t.Context(), "missing", 10)
if err != nil {
t.Fatalf("history for an unknown kind must not error: %v", err)
}
if len(history) != 0 {
t.Fatalf("history = %+v, want empty", history)
}
}
+41
View File
@@ -32,6 +32,22 @@ type controlPlaneResourceResponse struct {
Resource controlPlaneResource `json:"resource"`
}
// controlPlaneRevision is one entry of a resource's audit trail. Value is the
// payload a restore sends back through the replace command, so it stays raw
// JSON rather than the base64 a proto bytes field would otherwise render as.
type controlPlaneRevision struct {
Version int64 `json:"version"`
Value json.RawMessage `json:"value"`
Actor string `json:"actor"`
Source string `json:"source"`
RequestID string `json:"request_id"`
At *time.Time `json:"at,omitempty"`
}
type controlPlaneHistoryResponse struct {
Revisions []controlPlaneRevision `json:"revisions"`
}
func (s *Server) handleControlPlaneCatalog(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
@@ -58,6 +74,31 @@ func (s *Server) handleControlPlaneQuery(w http.ResponseWriter, r *http.Request)
writeJSON(w, controlPlaneResourceResponse{Resource: controlPlaneResourceView(response.Resource)})
}
func (s *Server) handleControlPlaneHistory(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
return
}
response, err := s.ControlPlane.History(r.Context(), &controlpb.HistoryRequest{Kind: r.PathValue("kind")})
if err != nil {
writeControlPlaneError(w, err)
return
}
revisions := make([]controlPlaneRevision, 0, len(response.Revisions))
for _, revision := range response.Revisions {
view := controlPlaneRevision{
Version: revision.Version, Value: revision.ValueJson, Actor: revision.Actor,
Source: revision.Source, RequestID: revision.RequestId,
}
if revision.At != nil {
at := revision.At.AsTime()
view.At = &at
}
revisions = append(revisions, view)
}
writeJSON(w, controlPlaneHistoryResponse{Revisions: revisions})
}
func (s *Server) handleControlPlaneCommand(w http.ResponseWriter, r *http.Request) {
if s.ControlPlane == nil {
http.Error(w, "control plane unavailable", http.StatusServiceUnavailable)
+59 -3
View File
@@ -18,9 +18,11 @@ import (
)
type controlPlaneClientStub struct {
command *controlpb.CommandRequest
query *controlpb.Resource
err error
command *controlpb.CommandRequest
query *controlpb.Resource
history *controlpb.HistoryRequest
revisions []*controlpb.Revision
err error
}
func (f *controlPlaneClientStub) Catalog(context.Context, *controlpb.CatalogRequest, ...grpc.CallOption) (*controlpb.CatalogResponse, error) {
@@ -31,6 +33,11 @@ func (f *controlPlaneClientStub) Query(context.Context, *controlpb.QueryRequest,
return &controlpb.QueryResponse{Resource: f.query}, f.err
}
func (f *controlPlaneClientStub) History(_ context.Context, request *controlpb.HistoryRequest, _ ...grpc.CallOption) (*controlpb.HistoryResponse, error) {
f.history = request
return &controlpb.HistoryResponse{Revisions: f.revisions}, f.err
}
func (f *controlPlaneClientStub) Command(_ context.Context, request *controlpb.CommandRequest, _ ...grpc.CallOption) (*controlpb.CommandResponse, error) {
f.command = request
if f.err != nil {
@@ -87,3 +94,52 @@ func TestControlPlaneConflictMapsToHTTPConflict(t *testing.T) {
t.Fatalf("status = %d, want 409", response.Code)
}
}
func TestControlPlaneHistoryRendersRevisionsForRestore(t *testing.T) {
client := &controlPlaneClientStub{revisions: []*controlpb.Revision{
{Version: 2, ValueJson: []byte(`{"max_model_tool_steps":40}`), Actor: string(identity.SystemID), Source: "archie-ui", RequestId: "ui-2"},
{Version: 1, ValueJson: []byte(`{"max_model_tool_steps":25}`), Actor: "system:migration", Source: "legacy-config", RequestId: "import"},
}}
server := &Server{ControlPlane: client}
request := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/control-plane/resources/workflow-execution-settings/history", nil)
response := httptest.NewRecorder()
server.Handler().ServeHTTP(response, request)
if response.Code != http.StatusOK {
t.Fatalf("status = %d, body = %q", response.Code, response.Body.String())
}
if client.history.GetKind() != "workflow-execution-settings" {
t.Fatalf("history requested for %q", client.history.GetKind())
}
var got struct {
Revisions []struct {
Version int64 `json:"version"`
Value json.RawMessage `json:"value"`
Actor string `json:"actor"`
Source string `json:"source"`
} `json:"revisions"`
}
if err := json.Unmarshal(response.Body.Bytes(), &got); err != nil {
t.Fatal(err)
}
if len(got.Revisions) != 2 || got.Revisions[0].Version != 2 || got.Revisions[0].Actor != string(identity.SystemID) {
t.Fatalf("revisions = %+v", got.Revisions)
}
// The value is the restore payload: it has to survive as JSON, not base64.
if string(got.Revisions[1].Value) != `{"max_model_tool_steps":25}` {
t.Fatalf("older value = %s, want the JSON a replace can send back", got.Revisions[1].Value)
}
}
func TestControlPlaneHistoryWithoutAControlPlaneIsUnavailable(t *testing.T) {
server := &Server{}
request := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/control-plane/resources/limits/history", nil)
response := httptest.NewRecorder()
server.Handler().ServeHTTP(response, request)
if response.Code != http.StatusServiceUnavailable {
t.Fatalf("status = %d, want 503", response.Code)
}
}
+1
View File
@@ -248,6 +248,7 @@ func (s *Server) registerMappingAndBindingRoutes(mux *http.ServeMux) {
func (s *Server) registerConfigAndLogRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/control-plane/catalog", s.handleControlPlaneCatalog)
mux.HandleFunc("GET /api/control-plane/resources/{kind}", s.handleControlPlaneQuery)
mux.HandleFunc("GET /api/control-plane/resources/{kind}/history", s.handleControlPlaneHistory)
mux.HandleFunc("POST /api/control-plane/resources/{kind}/commands/{command}", s.handleControlPlaneCommand)
mux.HandleFunc("GET /api/control-plane/watch/{kind}", s.handleControlPlaneWatch)
mux.HandleFunc("GET /api/identities", s.handleIdentitiesList)
+19
View File
@@ -7,6 +7,7 @@ import "google/protobuf/timestamp.proto";
service ControlPlaneService {
rpc Catalog(CatalogRequest) returns (CatalogResponse);
rpc Query(QueryRequest) returns (QueryResponse);
rpc History(HistoryRequest) returns (HistoryResponse);
rpc Command(CommandRequest) returns (CommandResponse);
rpc Watch(WatchRequest) returns (stream WatchResponse);
}
@@ -38,6 +39,24 @@ message Resource {
message QueryRequest { string kind = 1; }
message QueryResponse { Resource resource = 1; }
// Revision is one entry of a resource's audit trail: the value that version
// held, and who changed it from where.
message Revision {
int64 version = 1;
bytes value_json = 2;
string actor = 3;
string source = 4;
string request_id = 5;
google.protobuf.Timestamp at = 6;
}
message HistoryRequest {
string kind = 1;
// Limit caps the revisions returned, newest first. Zero means the server's
// own default.
int32 limit = 2;
}
message HistoryResponse { repeated Revision revisions = 1; }
message CommandRequest {
string kind = 1;
string command = 2;
+1 -1
View File
@@ -1 +1 @@
.identities-page[data-v-8ab739de]{max-width:960px}.identity-create[data-v-8ab739de]{gap:.75rem;margin:1.5rem 0;display:flex}.identity-create input[data-v-8ab739de]{flex:1}.identity-create input[data-v-8ab739de],.identity-create select[data-v-8ab739de],.identity-create button[data-v-8ab739de],.actions button[data-v-8ab739de]{border:1px solid var(--border);background:var(--surface);color:inherit;border-radius:.5rem;padding:.6rem .8rem}.identity-list[data-v-8ab739de]{border-top:1px solid var(--border)}.identity-row[data-v-8ab739de]{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:1rem;padding:1rem 0;display:flex}.identity-row span[data-v-8ab739de]{color:var(--muted-foreground);text-transform:capitalize;margin-top:.2rem;font-size:.85rem;display:block}.actions[data-v-8ab739de]{gap:.5rem;display:flex}.actions .danger[data-v-8ab739de],.error[data-v-8ab739de]{color:var(--destructive)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24remLine truncated
.identities-page[data-v-8ab739de]{max-width:960px}.identity-create[data-v-8ab739de]{gap:.75rem;margin:1.5rem 0;display:flex}.identity-create input[data-v-8ab739de]{flex:1}.identity-create input[data-v-8ab739de],.identity-create select[data-v-8ab739de],.identity-create button[data-v-8ab739de],.actions button[data-v-8ab739de]{border:1px solid var(--border);background:var(--surface);color:inherit;border-radius:.5rem;padding:.6rem .8rem}.identity-list[data-v-8ab739de]{border-top:1px solid var(--border)}.identity-row[data-v-8ab739de]{border-bottom:1px solid var(--border);justify-content:space-between;align-items:center;gap:1rem;padding:1rem 0;display:flex}.identity-row span[data-v-8ab739de]{color:var(--muted-foreground);text-transform:capitalize;margin-top:.2rem;font-size:.85rem;display:block}.actions[data-v-8ab739de]{gap:.5rem;display:flex}.actions .danger[data-v-8ab739de],.error[data-v-8ab739de]{color:var(--destructive)}@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-scrollbar-thumb:#0000;--tw-scrollbar-track:#0000;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24remLine truncated
+2 -2
View File
@@ -15,5 +15,5 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
Defaulting to \`null\`.`),null)}function Tx(e){return Cx(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${bx}\`.`),bx)}var Ex=N({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:bx},getValueLabel:{type:Function,required:!1,default:(e,t)=>Cx(e)?`${Math.round(e/t*bx)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;X();let i=yh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=yh(n,`max`,r,{passive:n.max===void 0});M(()=>i.value,async e=>{let t=wx(e,n.max);t!==e&&(await ar(),i.value=t)},{immediate:!0}),M(()=>n.max,e=>{let t=Tx(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=G(()=>Um(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Sx({modelValue:i,max:a,progressState:o}),(e,t)=>(L(),z(A(Z),{"as-child":e.asChild,as:e.as,"aria-valuemax":A(a),"aria-valuemin":0,"aria-valuenow":Cx(A(i))?A(i):void 0,"aria-valuetext":e.getValueText?.(A(i),A(a)),"aria-label":e.getValueLabel(A(i),A(a)),role:`progressbar`,"data-state":o.value,"data-value":A(i)??void 0,"data-max":A(a)},{default:j(()=>[F(e.$slots,`default`,{modelValue:A(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),Dx=N({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=xx();return X(),(e,r)=>(L(),z(A(Z),W(t,{"data-state":A(n).progressState.value,"data-value":A(n).modelValue?.value??void 0,"data-max":A(n).max.value}),{default:j(()=>[F(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),Ox=[` `,`Enter`,`ArrowUp`,`ArrowDown`],kx=[` `,`Enter`];function Ax(e,t,n){return e===void 0?!1:Array.isArray(e)?e.some(e=>jx(e,t,n)):jx(e,t,n)}function jx(e,t,n){return e===void 0||t===void 0?!1:typeof e==`string`?e===t:typeof n==`function`?n(e,t):typeof n==`string`?e?.[n]===t?.[n]:Rm(e,t)}function Mx(e){return e==null||e===``||Array.isArray(e)&&e.length===0}var Nx=[`value`],[Px,Fx]=Bm(`SelectRoot`),Ix=N({inheritAttrs:!1,__name:`SelectRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1,default:void 0},nullableValue:{type:String,required:!1,default:``},by:{type:[String,Function],required:!1},dir:{type:String,required:!1},multiple:{type:Boolean,required:!1},autocomplete:{type:String,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:modelValue`,`update:open`],setup(e,{emit:t}){let n=e,r=t,{required:i,disabled:a,multiple:o,dir:s}=En(n),c=yh(n,`modelValue`,r,{defaultValue:n.defaultValue??(o.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),l=yh(n,`open`,r,{defaultValue:n.defaultOpen,passive:n.open===void 0}),u=k(),d=k(),f=k({x:0,y:0}),p=G(()=>o.value&&Array.isArray(c.value)?c.value?.length===0:Um(c.value));D_({isProvider:!0});let m=Fh(s),h=Bh(u),g=k(new Set),_=G(()=>Array.from(g.value).map(e=>e.value).join(`;`));function v(e){if(o.value){let t=Array.isArray(c.value)?[...c.value]:[],r=t.findIndex(t=>jx(t,e,n.by));r===-1?t.push(e):t.splice(r,1),c.value=[...t]}else c.value=e}function y(e){return Array.from(g.value).find(t=>Ax(e,t.value,n.by))}return Fx({triggerElement:u,onTriggerChange:e=>{u.value=e},valueElement:d,onValueElementChange:e=>{d.value=e},contentId:``,modelValue:c,onValueChange:v,by:n.by,open:l,multiple:o,required:i,onOpenChange:e=>{l.value=e},dir:m,triggerPointerDownPosRef:f,disabled:a,isEmptyModelValue:p,optionsSet:g,onOptionAdd:e=>{let t=y(e.value);t&&g.value.delete(t),g.value.add(e)},onOptionRemove:e=>{let t=y(e.value);t&&g.value.delete(t)}}),(e,t)=>(L(),z(A(B_),null,{default:j(()=>[F(e.$slots,`default`,{modelValue:A(c),open:A(l)}),A(h)&&e.name?(L(),z(Lx,{key:_.value,"aria-hidden":`true`,tabindex:`-1`,multiple:A(o),required:A(i),name:e.name,autocomplete:e.autocomplete,disabled:A(a),value:A(c)},{default:j(()=>[A(Um)(A(c))?(L(),R(`option`,{key:0,value:e.nullableValue},null,8,Nx)):U(`v-if`,!0),(L(!0),R(I,null,P(Array.from(g.value),e=>(L(),R(`option`,W({key:e.value??``},{ref_for:!0},e),null,16))),128))]),_:1},8,[`multiple`,`required`,`name`,`autocomplete`,`disabled`,`value`])):U(`v-if`,!0)]),_:3}))}}),Lx=N({__name:`BubbleSelect`,props:{autocomplete:{type:String,required:!1},autofocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},form:{type:String,required:!1},multiple:{type:Boolean,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},size:{type:Number,required:!1},value:{type:null,required:!1}},setup(e){let t=e,n=k(),r=Px();M(()=>t.value,(e,t)=>{let r=window.HTMLSelectElement.prototype,i=Object.getOwnPropertyDescrLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:nT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>nT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=iT(c),u=e+1<n.length?iT(n[e+1]):null;if(l&&u&&aT(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=iT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>nT(e)),rows:r.map(e=>e.map(e=>nT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:nT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:nT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function iT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(eT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,DT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>sj?`${n.slice(0,sj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var lj=[`title`],uj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>MA(n.event)),a=G(()=>cj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,lj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),dj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},fj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,dj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(uj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),pj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),mj=`archie.setup-complete.dismissed.v1`;function hj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(mj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function gj(e=globalThis.localStorage){e?.setItem?.(mj,`1`)}var _j={class:`text-lg font-semibold text-link`},vj={class:`flex flex-col gap-3`},yj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},bj=N({__name:`SetupPanel`,setup(e){let t=k(hj(TA.value));M(TA,()=>{t.value=hj(TA.value)});let n=G(()=>TA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){gj(),t.value=hj(TA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,_j,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(pj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,vj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,yj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
`)}),t}function iT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function aT(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oT={class:`[overflow-wrap:anywhere]`},sT={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},cT={class:`font-mono text-[0.85em]`},lT={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},uT={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},dT={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},fT={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},pT={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},mT={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},hT={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},gT={key:8,class:`mb-2.5 last:mb-0`},_T=N({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=G(()=>rT(t.text));return(e,t)=>(L(),R(`div`,oT,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(I,{key:t},[e.kind===`pre`?(L(),R(`pre`,sT,[B(`code`,cT,O(e.code),1)])):e.kind===`table`?(L(),R(`table`,lT,[B(`thead`,null,[B(`tr`,null,[(L(!0),R(I,null,P(e.head,(e,t)=>(L(),R(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[V(eT,{inline:e},null,8,[`inline`])]))),128))])]),B(`tbody`,null,[(L(!0),R(I,null,P(e.rows,(e,t)=>(L(),R(`tr`,{key:t},[(L(!0),R(I,null,P(e,(e,t)=>(L(),R(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[V(eT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(L(),R(`blockquote`,uT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(L(),R(`h1`,dT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(L(),R(`h2`,fT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(L(),R(`h3`,pT,[V(eT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(L(),R(`ul`,mT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(L(),R(`ol`,hT,[(L(!0),R(I,null,P(e.items,(e,t)=>(L(),R(`li`,{key:t},[V(eT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(L(),R(`p`,gT,[V(eT,{inline:e.inline},null,8,[`inline`])])):U(``,!0)],64))),128))]))}}),vT={class:`truncate`},yT=N({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ma(`RouterLink`);return L(),z(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:j(()=>[V(A(yd),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),B(`span`,vT,O(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),bT={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},xT={class:`font-semibold text-foreground`},ST={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},CT=N({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=G(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=G(()=>t.tool.parameters||t.tool.Parameters||``),i=G(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=G(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(L(),z(yT,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(L(),R(`div`,bT,[V(A(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),B(`span`,xT,O(n.value),1),r.value?(L(),R(`code`,ST,O(r.value),1)):U(``,!0),B(`span`,{class:D(A(J)(`text-fg-muted`,i.value&&`text-danger`))},O(a.value),3)]))}}),wT={key:0,class:`mb-2 grid gap-0.5 text-xs`},TT={key:2,class:`whitespace-pre-wrap`},ET=N({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),R(`div`,{class:D([`flex`,e.assistant?`justify-start`:`justify-end`])},[B(`div`,{class:D(A(J)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(L(),R(`div`,wT,[(L(!0),R(I,null,P(e.tools,(t,n)=>(L(),z(CT,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):U(``,!0),e.assistant?(L(),z(_T,{key:1,text:e.text},null,8,[`text`])):(L(),R(`div`,TT,O(e.text),1)),F(t.$slots,`default`)],2)],2))}}),DT={class:`w-full self-center justify-self-center py-6 text-center`},OT={class:`grid gap-2`},kT=[`onClick`],AT=N({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),R(`div`,DT,[t[0]||=B(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 placLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>gj?`${n.slice(0,gj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var vj=[`title`],yj=N({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=G(()=>VA(n.event)),a=G(()=>_j(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=G(()=>n.event.at?ak(n.event.at):`—`);return(e,t)=>(L(),z(A(IO),{class:D(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[du(lu(o,[`prevent`]),[`enter`]),du(lu(o,[`prevent`]),[`space`])]},{default:j(()=>[V(A($),{class:`font-medium`},{default:j(()=>[H(O(n.event.kind||n.event.type||`event`),1)]),_:1}),V(A($),{class:`font-mono`},{default:j(()=>[H(O(i.value>0?`#${i.value}`:`—`),1)]),_:1}),V(A($),{class:`w-[55%] max-w-0`},{default:j(()=>[B(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},O(a.value.text),9,vj)]),_:1}),V(A($),null,{default:j(()=>[H(O(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),bj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},xj=N({__name:`LiveActivityCard`,setup(e){let t=$T(),{activity:n,streamKind:r,streamState:i}=ad(JD());function a(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(L(),z(A(_O),null,{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...t[0]||=[H(`Live activity`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...t[1]||=[H(`Last 50, newest first`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[V(A(zO),{variant:A(r)},{default:j(()=>[H(O(A(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[B(`div`,bj,[V(A(PO),null,{default:j(()=>[V(A(RO),null,{default:j(()=>[V(A(IO),null,{default:j(()=>[V(A(LO),null,{default:j(()=>[...t[2]||=[H(`Event`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[3]||=[H(`Task`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[4]||=[H(`Detail`,-1)]]),_:1}),V(A(LO),null,{default:j(()=>[...t[5]||=[H(`When`,-1)]]),_:1})]),_:1})]),_:1}),V(A(FO),null,{default:j(()=>[A(n).length?(L(!0),R(I,{key:1},P(A(n),(e,t)=>(L(),z(yj,{key:t,event:e,onOpen:a},null,8,[`event`]))),128)):(L(),z(A(IO),{key:0},{default:j(()=>[V(A($),{colspan:`4`},{default:j(()=>[V(A(wO),null,{default:j(()=>[V(A(DO),null,{default:j(()=>[V(A(AO),null,{default:j(()=>[...t[6]||=[H(`Waiting for activity`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})])]),_:1})]),_:1}))}}),Sj=N({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=QS(t,`class`);return(e,r)=>(L(),z(A(Ex),W({"data-slot":`progress`},A(n),{class:A(J)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:j(()=>[V(A(Dx),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ve(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),Cj=`archie.setup-complete.dismissed.v1`;function wj(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(Cj),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Tj(e=globalThis.localStorage){e?.setItem?.(Cj,`1`)}var Ej={class:`text-lg font-semibold text-link`},Dj={class:`flex flex-col gap-3`},Oj={key:0,class:`mt-0.5 text-xs text-fg-subtle`},kj=N({__name:`SetupPanel`,setup(e){let t=k(wj(PA.value));M(PA,()=>{t.value=wj(PA.value)});let n=G(()=>PA.value?.steps??[]),r=G(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Tj(),t.value=wj(PA.value)}return(e,a)=>t.value.kind===`incomplete`?(L(),z(A(_O),{key:0},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[0]||=[H(`Finish setting up`,-1)]]),_:1}),V(A(bO),null,{default:j(()=>[...a[1]||=[H(`Archie needs these before it can work on its own.`,-1)]]),_:1}),V(A(vO),null,{default:j(()=>[B(`span`,Ej,O(r.value)+`%`,1)]),_:1})]),_:1}),V(A(yO),null,{default:j(()=>[V(A(Sj),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),B(`ul`,Dj,[(L(!0),R(I,null,P(n.value,(e,t)=>(L(),R(`li`,{key:t,class:`flex items-start gap-3`},[B(`span`,{class:D([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(L(),z(A(bd),{key:0,class:`size-3`})):U(``,!0)],2),B(`div`,null,[B(`div`,{class:D([`text-sm`,e.done?`text-fg-muted line-through`:``])},O(e.title),3),e.detail?(L(),R(`div`,Oj,O(e.detail),1)):U(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(L(),z(A(_O),{key:1},{default:j(()=>[V(A(SO),null,{default:j(()=>[V(A(CO),null,{default:j(()=>[...a[2]||=[H(`Setup complete`Line truncated
@@ -9,6 +9,7 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa
import { Spinner } from "@/components/ui/spinner";
import { useControlPlaneStore, type ResourceDescriptor } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import ResourceHistory from "./ResourceHistory.vue";
interface JSONSchemaProperty {
type?: "integer" | "number" | "string" | "boolean";
@@ -113,5 +114,6 @@ async function save(): Promise<void> {
</Button>
</div>
</form>
<ResourceHistory :kind="descriptor.kind" />
</ConfigCard>
</template>
+89
View File
@@ -0,0 +1,89 @@
<script setup lang="ts">
import { computed, ref } from "vue";
import { RotateCcw } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { ago } from "@/lib/format";
import { useControlPlaneStore, type ResourceRevision } from "@/stores/control-plane";
/**
* A resource's audit trail, and the way back to any earlier value.
*
* Restoring is not its own command: a revision carries the value it held, so
* putting it back is an ordinary replace against the version currently stored.
* That keeps the restore in the same history as every other edit rather than
* rewriting the past.
*
* The list loads when it is opened. A settings page that nobody is auditing
* should not pay for the query on every render.
*/
const props = defineProps<{ kind: string }>();
const store = useControlPlaneStore();
const state = computed(() => store.stateFor(props.kind));
const revisions = ref<ResourceRevision[]>([]);
const open = ref(false);
const loading = ref(false);
const error = ref("");
async function load(): Promise<void> {
loading.value = true;
error.value = "";
try {
revisions.value = await store.history(props.kind);
} catch (err) {
error.value = String((err as Error).message || err);
} finally {
loading.value = false;
}
}
async function toggle(): Promise<void> {
open.value = !open.value;
if (open.value) await load();
}
async function restore(revision: ResourceRevision): Promise<void> {
if (await store.replace(props.kind, revision.value)) await load();
}
</script>
<template>
<div class="mt-5 border-t border-border pt-4">
<Button variant="ghost" size="sm" :aria-expanded="open" @click="toggle">
<Spinner v-if="loading" data-icon="inline-start" />
{{ open ? "Hide history" : "History" }}
</Button>
<p v-if="error" class="mt-2 text-sm text-destructive" role="alert">{{ error }}</p>
<div v-else-if="open && !loading" class="mt-3">
<p v-if="!revisions.length" class="text-sm text-muted-foreground">No changes recorded yet.</p>
<ul v-else class="space-y-1">
<li
v-for="revision in revisions"
:key="revision.version"
class="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-3 border-t border-border py-2 first:border-t-0"
>
<Badge :variant="revision.version === state.resource?.version ? 'ok' : 'idle'">v{{ revision.version }}</Badge>
<span class="min-w-0 truncate text-sm text-fg-muted" :title="`${revision.actor} via ${revision.source}`">
{{ revision.actor }} <span class="text-fg-subtle">via {{ revision.source }}</span>
<span v-if="revision.at" class="text-fg-subtle"> · {{ ago(revision.at) }}</span>
</span>
<Button
v-if="revision.version !== state.resource?.version"
variant="outline"
size="sm"
:disabled="state.saving"
:title="`Replace the current value with version ${revision.version}`"
@click="restore(revision)"
>
<RotateCcw /> Restore
</Button>
</li>
</ul>
</div>
</div>
</template>
@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { cloneControlPlaneValue, useControlPlaneStore, type ResourceDescriptor } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import ResourceHistory from "./ResourceHistory.vue";
import StructuredValueEditor from "./StructuredValueEditor.vue";
const props = defineProps<{ descriptor: ResourceDescriptor; rootPath?: string }>();
@@ -38,5 +39,6 @@ async function save(): Promise<void> {
</Button>
</div>
</form>
<ResourceHistory :kind="descriptor.kind" />
</ConfigCard>
</template>
+19 -1
View File
@@ -22,6 +22,19 @@ export interface ControlPlaneResource {
interface ResourceResponse { resource: ControlPlaneResource }
/** One entry of a resource's audit trail. `value` is what that version held,
* which is also the payload a restore replays through the replace command. */
export interface ResourceRevision {
version: number;
value: unknown;
actor: string;
source: string;
request_id: string;
at?: string;
}
interface HistoryResponse { revisions?: ResourceRevision[] }
export interface ResourceState {
resource?: ControlPlaneResource;
loading: boolean;
@@ -178,6 +191,11 @@ export const useControlPlaneStore = defineStore("control-plane", () => {
}
}
async function history(kind: string): Promise<ResourceRevision[]> {
const response = await request<HistoryResponse>(`/api/control-plane/resources/${encodeURIComponent(kind)}/history`);
return response.revisions ?? [];
}
/** The shipped definitions the catalog offers as "restore shipped". */
function shippedWorkflows(): WorkflowDefinitionCollection {
const defaults = catalog.value.find((resource) => resource.kind === "workflow-definitions")?.defaults_json;
@@ -189,5 +207,5 @@ export const useControlPlaneStore = defineStore("control-plane", () => {
}
}
return { catalog, catalogError, states, genericResources, load, replace, shippedWorkflows, stateFor };
return { catalog, catalogError, states, genericResources, history, load, replace, shippedWorkflows, stateFor };
});