feat(eda): name and delete capture sources; an armed binding blocks the delete

This commit is contained in:
sam committed 2026-10-05 21:05:58 +11:00
1 parent 738044a949
commit d295fa2680
22 files changed
+1103 -592

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -111,6 +111,8 @@ const (
StateStoreService_ListSources_FullMethodName = "/state.v1.StateStoreService/ListSources"
StateStoreService_SetSourceSigning_FullMethodName = "/state.v1.StateStoreService/SetSourceSigning"
StateStoreService_SetSourceSecret_FullMethodName = "/state.v1.StateStoreService/SetSourceSecret"
StateStoreService_SetSourceName_FullMethodName = "/state.v1.StateStoreService/SetSourceName"
StateStoreService_DeleteSource_FullMethodName = "/state.v1.StateStoreService/DeleteSource"
StateStoreService_ArmedBindingsForSource_FullMethodName = "/state.v1.StateStoreService/ArmedBindingsForSource"
StateStoreService_RecordDispatch_FullMethodName = "/state.v1.StateStoreService/RecordDispatch"
StateStoreService_SetDispatchTask_FullMethodName = "/state.v1.StateStoreService/SetDispatchTask"
@@ -315,6 +317,8 @@ type StateStoreServiceClient interface {
ListSources(ctx context.Context, in *ListSourcesRequest, opts ...grpc.CallOption) (*ListSourcesResponse, error)
SetSourceSigning(ctx context.Context, in *SetSourceSigningRequest, opts ...grpc.CallOption) (*SetSourceSigningResponse, error)
SetSourceSecret(ctx context.Context, in *SetSourceSecretRequest, opts ...grpc.CallOption) (*SetSourceSecretResponse, error)
SetSourceName(ctx context.Context, in *SetSourceNameRequest, opts ...grpc.CallOption) (*SetSourceNameResponse, error)
DeleteSource(ctx context.Context, in *DeleteSourceRequest, opts ...grpc.CallOption) (*DeleteSourceResponse, error)
// Dispatch
ArmedBindingsForSource(ctx context.Context, in *ArmedBindingsForSourceRequest, opts ...grpc.CallOption) (*ArmedBindingsForSourceResponse, error)
RecordDispatch(ctx context.Context, in *RecordDispatchRequest, opts ...grpc.CallOption) (*RecordDispatchResponse, error)
@@ -1310,6 +1314,26 @@ func (c *stateStoreServiceClient) SetSourceSecret(ctx context.Context, in *SetSo
return out, nil
}
func (c *stateStoreServiceClient) SetSourceName(ctx context.Context, in *SetSourceNameRequest, opts ...grpc.CallOption) (*SetSourceNameResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SetSourceNameResponse)
err := c.cc.Invoke(ctx, StateStoreService_SetSourceName_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *stateStoreServiceClient) DeleteSource(ctx context.Context, in *DeleteSourceRequest, opts ...grpc.CallOption) (*DeleteSourceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeleteSourceResponse)
err := c.cc.Invoke(ctx, StateStoreService_DeleteSource_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *stateStoreServiceClient) ArmedBindingsForSource(ctx context.Context, in *ArmedBindingsForSourceRequest, opts ...grpc.CallOption) (*ArmedBindingsForSourceResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ArmedBindingsForSourceResponse)
@@ -1746,6 +1770,8 @@ type StateStoreServiceServer interface {
ListSources(context.Context, *ListSourcesRequest) (*ListSourcesResponse, error)
SetSourceSigning(context.Context, *SetSourceSigningRequest) (*SetSourceSigningResponse, error)
SetSourceSecret(context.Context, *SetSourceSecretRequest) (*SetSourceSecretResponse, error)
SetSourceName(context.Context, *SetSourceNameRequest) (*SetSourceNameResponse, error)
DeleteSource(context.Context, *DeleteSourceRequest) (*DeleteSourceResponse, error)
// Dispatch
ArmedBindingsForSource(context.Context, *ArmedBindingsForSourceRequest) (*ArmedBindingsForSourceResponse, error)
RecordDispatch(context.Context, *RecordDispatchRequest) (*RecordDispatchResponse, error)
@@ -2079,6 +2105,12 @@ func (UnimplementedStateStoreServiceServer) SetSourceSigning(context.Context, *S
func (UnimplementedStateStoreServiceServer) SetSourceSecret(context.Context, *SetSourceSecretRequest) (*SetSourceSecretResponse, error) {
return nil, status.Error(codes.Unimplemented, "method SetSourceSecret not implemented")
}
func (UnimplementedStateStoreServiceServer) SetSourceName(context.Context, *SetSourceNameRequest) (*SetSourceNameResponse, error) {
return nil, status.Error(codes.Unimplemented, "method SetSourceName not implemented")
}
func (UnimplementedStateStoreServiceServer) DeleteSource(context.Context, *DeleteSourceRequest) (*DeleteSourceResponse, error) {
return nil, status.Error(codes.Unimplemented, "method DeleteSource not implemented")
}
func (UnimplementedStateStoreServiceServer) ArmedBindingsForSource(context.Context, *ArmedBindingsForSourceRequest) (*ArmedBindingsForSourceResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ArmedBindingsForSource not implemented")
}
@@ -3817,6 +3849,42 @@ func _StateStoreService_SetSourceSecret_Handler(srv interface{}, ctx context.Con
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_SetSourceName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetSourceNameRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StateStoreServiceServer).SetSourceName(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: StateStoreService_SetSourceName_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StateStoreServiceServer).SetSourceName(ctx, req.(*SetSourceNameRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_DeleteSource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteSourceRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StateStoreServiceServer).DeleteSource(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: StateStoreService_DeleteSource_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StateStoreServiceServer).DeleteSource(ctx, req.(*DeleteSourceRequest))
}
return interceptor(ctx, in, info, handler)
}
func _StateStoreService_ArmedBindingsForSource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ArmedBindingsForSourceRequest)
if err := dec(in); err != nil {
@@ -4627,6 +4695,14 @@ var StateStoreService_ServiceDesc = grpc.ServiceDesc{
MethodName: "SetSourceSecret",
Handler: _StateStoreService_SetSourceSecret_Handler,
},
{
MethodName: "SetSourceName",
Handler: _StateStoreService_SetSourceName_Handler,
},
{
MethodName: "DeleteSource",
Handler: _StateStoreService_DeleteSource_Handler,
},
{
MethodName: "ArmedBindingsForSource",
Handler: _StateStoreService_ArmedBindingsForSource_Handler,
+3 -1
View File
@@ -35,7 +35,9 @@ var (
// captures and binding matchers reference it, so it does not change after
// creation. Secret is the HMAC key a signed sender signs with.
type Source struct {
Path string `json:"path"`
Path string `json:"path"`
// Name is the operator's label; Path stays the source's identity.
Name string `json:"name,omitempty"`
Signing Signing `json:"signing"`
Secret string `json:"secret,omitempty"`
CreatedAt time.Time `json:"created_at"`
@@ -248,6 +248,10 @@ type SourceStore interface {
ListSources(ctx context.Context) ([]source.Source, error)
SetSourceSigning(ctx context.Context, path string, from, to source.Signing) error
SetSourceSecret(ctx context.Context, path, secret string) error
SetSourceName(ctx context.Context, path, name string) error
// DeleteSource refuses with ErrSourceInUse while an armed binding fires
// on the source.
DeleteSource(ctx context.Context, path string) error
}
// DispatchLedger reads the binding dispatch ledger.
@@ -488,6 +492,9 @@ var (
ErrEventTypeNotFound = errors.New("store: event type not found")
// ErrSourceNotFound is returned when a source path does not exist.
ErrSourceNotFound = errors.New("store: source not found")
// ErrSourceInUse is returned when deleting a source an armed binding
// fires on.
ErrSourceInUse = errors.New("store: source has an armed binding")
// ErrSourcePathTaken is returned when a new source's path is in use.
ErrSourcePathTaken = errors.New("store: source path already taken")
// ErrSourceSigningStale is returned when a signing write's expected
@@ -9,6 +9,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/binding"
"github.com/samcharles93/archie-core/internal/domain/eventtype"
"github.com/samcharles93/archie-core/internal/domain/mapping"
"github.com/samcharles93/archie-core/internal/domain/source"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres"
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/pgstore"
@@ -148,4 +149,24 @@ func TestBindingLifecycle(t *testing.T) {
if err := eda.PauseBinding(ctx, "missing"); !errors.Is(err, storecontract.ErrBindingNotFound) {
t.Fatalf("pause of a missing binding = %v, want ErrBindingNotFound", err)
}
// A source is not deleted while an armed binding fires on it.
if err := eda.InsertSource(ctx, source.Source{Path: "forge", Signing: source.SigningSigned}); err != nil {
t.Fatal(err)
}
if err := eda.ApproveBinding(ctx, id); err != nil {
t.Fatal(err)
}
if err := eda.DeleteSource(ctx, "forge"); !errors.Is(err, storecontract.ErrSourceInUse) {
t.Fatalf("delete of a source an armed binding fires on = %v, want ErrSourceInUse", err)
}
if err := eda.PauseBinding(ctx, id); err != nil {
t.Fatal(err)
}
if err := eda.DeleteSource(ctx, "forge"); err != nil {
t.Fatalf("delete of a source with no armed binding = %v", err)
}
if err := eda.DeleteSource(ctx, "forge"); !errors.Is(err, storecontract.ErrSourceNotFound) {
t.Fatalf("second delete = %v, want ErrSourceNotFound", err)
}
}
@@ -0,0 +1,10 @@
-- sources.name is the operator's label for a source; its path stays the
-- identity captures and bindings reference.
-- +goose Up
ALTER TABLE sources ADD COLUMN name text NOT NULL DEFAULT '';
-- +goose Down
ALTER TABLE sources DROP COLUMN name;
@@ -189,6 +189,21 @@ func (q *Queries) DeletePlaybookDispatches(ctx context.Context, playbookID strin
return err
}
const deleteUnboundSource = `-- name: DeleteUnboundSource :execrows
DELETE FROM sources s WHERE s.path = $1
AND NOT EXISTS (SELECT 1 FROM bindings b WHERE b.source = s.path AND b.status = 'armed')
`
// A source an armed binding fires on is not deleted: the binding would
// silently stop receiving events.
func (q *Queries) DeleteUnboundSource(ctx context.Context, path string) (int64, error) {
result, err := q.db.Exec(ctx, deleteUnboundSource, path)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const deriveSources = `-- name: DeriveSources :exec
SELECT derive_sources()
`
@@ -342,7 +357,7 @@ func (q *Queries) GetMapping(ctx context.Context, id string) (GetMappingRow, err
}
const getSource = `-- name: GetSource :one
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id FROM sources WHERE path = $1
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id, name FROM sources WHERE path = $1
`
func (q *Queries) GetSource(ctx context.Context, path string) (Source, error) {
@@ -356,6 +371,7 @@ func (q *Queries) GetSource(ctx context.Context, path string) (Source, error) {
&i.UpdatedAt,
&i.OrgID,
&i.WorkspaceID,
&i.Name,
)
return i, err
}
@@ -837,7 +853,7 @@ func (q *Queries) ListMappings(ctx context.Context) ([]ListMappingsRow, error) {
}
const listSources = `-- name: ListSources :many
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id FROM sources ORDER BY created_at DESC, path
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id, name FROM sources ORDER BY created_at DESC, path
`
func (q *Queries) ListSources(ctx context.Context) ([]Source, error) {
@@ -857,6 +873,7 @@ func (q *Queries) ListSources(ctx context.Context) ([]Source, error) {
&i.UpdatedAt,
&i.OrgID,
&i.WorkspaceID,
&i.Name,
); err != nil {
return nil, err
}
@@ -958,6 +975,23 @@ func (q *Queries) SetBindingDispatchTask(ctx context.Context, arg SetBindingDisp
return err
}
const setSourceName = `-- name: SetSourceName :execrows
UPDATE sources SET name = $2, updated_at = now() WHERE path = $1
`
type SetSourceNameParams struct {
Path string
Name string
}
func (q *Queries) SetSourceName(ctx context.Context, arg SetSourceNameParams) (int64, error) {
result, err := q.db.Exec(ctx, setSourceName, arg.Path, arg.Name)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const setSourceSecret = `-- name: SetSourceSecret :execrows
UPDATE sources SET secret = $2, updated_at = now() WHERE path = $1
`
@@ -344,6 +344,7 @@ type Source struct {
UpdatedAt time.Time
OrgID string
WorkspaceID string
Name string
}
type StepExecution struct {
@@ -152,10 +152,10 @@ SELECT pg_advisory_xact_lock(hashtext('event_types:' || sqlc.arg(source)::text))
INSERT INTO sources (path, signing, secret) VALUES ($1, $2, $3);
-- name: GetSource :one
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id FROM sources WHERE path = $1;
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id, name FROM sources WHERE path = $1;
-- name: ListSources :many
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id FROM sources ORDER BY created_at DESC, path;
SELECT path, signing, secret, created_at, updated_at, org_id, workspace_id, name FROM sources ORDER BY created_at DESC, path;
-- name: SetSourceSigning :execrows
UPDATE sources SET signing = sqlc.arg(to_signing), updated_at = now()
@@ -164,6 +164,15 @@ WHERE path = sqlc.arg(path) AND signing = sqlc.arg(from_signing);
-- name: SetSourceSecret :execrows
UPDATE sources SET secret = $2, updated_at = now() WHERE path = $1;
-- name: SetSourceName :execrows
UPDATE sources SET name = $2, updated_at = now() WHERE path = $1;
-- name: DeleteUnboundSource :execrows
-- A source an armed binding fires on is not deleted: the binding would
-- silently stop receiving events.
DELETE FROM sources s WHERE s.path = $1
AND NOT EXISTS (SELECT 1 FROM bindings b WHERE b.source = s.path AND b.status = 'armed');
-- name: SourceExists :one
SELECT EXISTS (SELECT 1 FROM sources WHERE path = $1);
+32 -1
View File
@@ -102,6 +102,37 @@ func (s *EDA) SetSourceSecret(ctx context.Context, path, secret string) error {
return nil
}
// SetSourceName relabels a source.
func (s *EDA) SetSourceName(ctx context.Context, path, name string) error {
n, err := s.q.SetSourceName(ctx, postgresdb.SetSourceNameParams{Path: path, Name: name})
if err != nil {
return fmt.Errorf("edastore: set source name: %w", err)
}
if n == 0 {
return storecontract.ErrSourceNotFound
}
return nil
}
// DeleteSource deletes a source no armed binding fires on.
func (s *EDA) DeleteSource(ctx context.Context, path string) error {
n, err := s.q.DeleteUnboundSource(ctx, path)
if err != nil {
return fmt.Errorf("edastore: delete source: %w", err)
}
if n > 0 {
return nil
}
exists, err := s.q.SourceExists(ctx, path)
if err != nil {
return fmt.Errorf("edastore: delete source: %w", err)
}
if exists {
return storecontract.ErrSourceInUse
}
return storecontract.ErrSourceNotFound
}
// sealSecret encrypts a non-empty secret when a cipher is configured.
func (s *EDA) sealSecret(secret string) (string, error) {
if s.cipher == nil || secret == "" {
@@ -124,7 +155,7 @@ func (s *EDA) sourceValue(r postgresdb.Source) (source.Source, error) {
secret = plain
}
return source.Source{
Path: r.Path, Signing: source.Signing(r.Signing), Secret: secret,
Path: r.Path, Name: r.Name, Signing: source.Signing(r.Signing), Secret: secret,
CreatedAt: r.CreatedAt, UpdatedAt: r.UpdatedAt,
}, nil
}
@@ -659,6 +659,16 @@ func (c *Client) SetSourceSigning(ctx context.Context, path string, from, to sou
return unmapError(err)
}
func (c *Client) SetSourceName(ctx context.Context, path, name string) error {
_, err := c.client.SetSourceName(ctx, &pb.SetSourceNameRequest{Path: path, Name: name})
return unmapError(err)
}
func (c *Client) DeleteSource(ctx context.Context, path string) error {
_, err := c.client.DeleteSource(ctx, &pb.DeleteSourceRequest{Path: path})
return unmapError(err)
}
func (c *Client) SetSourceSecret(ctx context.Context, path, secret string) error {
_, err := c.client.SetSourceSecret(ctx, &pb.SetSourceSecretRequest{Path: path, Secret: secret})
return unmapError(err)
@@ -954,6 +954,28 @@ func (s *server) SetSourceSecret(ctx context.Context, r *pb.SetSourceSecretReque
return &pb.SetSourceSecretResponse{}, nil
}
func (s *server) SetSourceName(ctx context.Context, r *pb.SetSourceNameRequest) (*pb.SetSourceNameResponse, error) {
ss, err := s.sources()
if err != nil {
return nil, err
}
if err := ss.SetSourceName(ctx, r.Path, r.Name); err != nil {
return nil, s.logErr("SetSourceName", err)
}
return &pb.SetSourceNameResponse{}, nil
}
func (s *server) DeleteSource(ctx context.Context, r *pb.DeleteSourceRequest) (*pb.DeleteSourceResponse, error) {
ss, err := s.sources()
if err != nil {
return nil, err
}
if err := ss.DeleteSource(ctx, r.Path); err != nil {
return nil, s.logErr("DeleteSource", err)
}
return &pb.DeleteSourceResponse{}, nil
}
// Dispatch
func (s *server) ArmedBindingsForSource(ctx context.Context, r *pb.ArmedBindingsForSourceRequest) (*pb.ArmedBindingsForSourceResponse, error) {
+3 -2
View File
@@ -211,7 +211,7 @@ func capturedEventValue(c *pb.CapturedEvent) storecontract.CapturedEvent {
func sourceProto(s source.Source) *pb.Source {
return &pb.Source{
Path: s.Path, Signing: string(s.Signing), Secret: s.Secret,
Path: s.Path, Name: s.Name, Signing: string(s.Signing), Secret: s.Secret,
CreatedAt: timestamp(s.CreatedAt), UpdatedAt: timestamp(s.UpdatedAt),
}
}
@@ -221,7 +221,7 @@ func sourceValue(s *pb.Source) source.Source {
return source.Source{}
}
return source.Source{
Path: s.Path, Signing: source.Signing(s.Signing), Secret: s.Secret,
Path: s.Path, Name: s.Name, Signing: source.Signing(s.Signing), Secret: s.Secret,
CreatedAt: timeValue(s.CreatedAt), UpdatedAt: timeValue(s.UpdatedAt),
}
}
@@ -496,6 +496,7 @@ var wireErrors = []struct {
{storecontract.ErrMappingNotFound, codes.NotFound, msgMappingNotFound},
{storecontract.ErrEventTypeNotFound, codes.NotFound, msgEventTypeNotFound},
{storecontract.ErrSourceNotFound, codes.NotFound, msgSourceNotFound},
{storecontract.ErrSourceInUse, codes.FailedPrecondition, storecontract.ErrSourceInUse.Error()},
{storecontract.ErrAlreadyDispatched, codes.AlreadyExists, msgAlreadyDispatched},
{storecontract.ErrCallNotYours, codes.PermissionDenied, storecontract.ErrCallNotYours.Error()},
{storecontract.ErrCallCallerNotRunning, codes.FailedPrecondition, storecontract.ErrCallCallerNotRunning.Error()},
+44
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"net/http"
"strings"
"time"
"github.com/samcharles93/archie-core/internal/domain/source"
@@ -131,6 +132,47 @@ func (s *Server) handleSourceSecret(w http.ResponseWriter, r *http.Request) {
writeJSON(w, src)
}
// handleSourceName relabels a source; its path does not change.
func (s *Server) handleSourceName(w http.ResponseWriter, r *http.Request) {
if !s.authorizeTaskMutation(w, r) {
return
}
src, ok := s.loadSource(w, r)
if !ok {
return
}
var request struct {
Name string `json:"name"`
}
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4<<10)).Decode(&request); err != nil {
http.Error(w, "invalid source name", http.StatusBadRequest)
return
}
src.Name = strings.TrimSpace(request.Name)
if err := s.Sources.SetSourceName(r.Context(), src.Path, src.Name); err != nil {
s.sourceError(w, "set source name", err)
return
}
src.Secret = ""
writeJSON(w, src)
}
// handleSourceDelete deletes a source no armed binding fires on.
func (s *Server) handleSourceDelete(w http.ResponseWriter, r *http.Request) {
if !s.authorizeTaskMutation(w, r) {
return
}
if s.Sources == nil {
http.Error(w, "sources not configured", http.StatusServiceUnavailable)
return
}
if err := s.Sources.DeleteSource(r.Context(), r.PathValue("path")); err != nil {
s.sourceError(w, "delete source", err)
return
}
w.WriteHeader(http.StatusNoContent)
}
func (s *Server) loadSource(w http.ResponseWriter, r *http.Request) (*source.Source, bool) {
if s.Sources == nil {
http.Error(w, "sources not configured", http.StatusServiceUnavailable)
@@ -156,6 +198,8 @@ func (s *Server) sourceError(w http.ResponseWriter, what string, err error) {
http.Error(w, "source signing changed; reload and retry", http.StatusConflict)
case errors.Is(err, storecontract.ErrSourceNotFound):
http.Error(w, "source not found", http.StatusNotFound)
case errors.Is(err, storecontract.ErrSourceInUse):
http.Error(w, "an armed binding fires on this source; pause or delete it first", http.StatusConflict)
default:
s.Log.Error(what, "err", err)
http.Error(w, what+" failed", http.StatusInternalServerError)
+2
View File
@@ -304,6 +304,8 @@ func (s *Server) registerMappingAndBindingRoutes(mux *http.ServeMux) {
mux.HandleFunc("POST /api/sources/{path}/signing", s.handleSourceSigning)
mux.HandleFunc("POST /api/sources/{path}/approve-unsigned", s.handleSourceApproveUnsigned)
mux.HandleFunc("POST /api/sources/{path}/secret", s.handleSourceSecret)
mux.HandleFunc("PUT /api/sources/{path}/name", s.handleSourceName)
mux.HandleFunc("DELETE /api/sources/{path}", s.handleSourceDelete)
}
func (s *Server) registerHarnessRoutes(mux *http.ServeMux) {
+10
View File
@@ -190,6 +190,8 @@ service StateStoreService {
rpc ListSources(ListSourcesRequest) returns (ListSourcesResponse);
rpc SetSourceSigning(SetSourceSigningRequest) returns (SetSourceSigningResponse);
rpc SetSourceSecret(SetSourceSecretRequest) returns (SetSourceSecretResponse);
rpc SetSourceName(SetSourceNameRequest) returns (SetSourceNameResponse);
rpc DeleteSource(DeleteSourceRequest) returns (DeleteSourceResponse);
// Dispatch
rpc ArmedBindingsForSource(ArmedBindingsForSourceRequest) returns (ArmedBindingsForSourceResponse);
@@ -557,6 +559,7 @@ message Source {
string secret = 3;
google.protobuf.Timestamp created_at = 4;
google.protobuf.Timestamp updated_at = 5;
string name = 6;
}
// WorkflowStat mirrors storecontract.WorkflowStat.
@@ -1119,6 +1122,13 @@ message DeleteBindingResponse {}
message ApproveBindingRequest { string id = 1; }
message ApproveBindingResponse {}
message SetSourceNameRequest {
string path = 1;
string name = 2;
}
message SetSourceNameResponse {}
message DeleteSourceRequest { string path = 1; }
message DeleteSourceResponse {}
message PauseBindingRequest { string id = 1; }
message PauseBindingResponse {}
message ResumeBindingRequest { string id = 1; }
+14 -14
View File
@@ -3,22 +3,22 @@ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],en
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
`)&&(mi(e,0)||ii(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!O(a)||a[0]===`.`||t&&!O(a)||u&&u.includes(a)){if(di(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&$t(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&hs(x,n,t),h&&lr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&Go(()=>{x&&hs(x,n,t),l&&g.enter(e),h&&lr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=fs(d[t]),g=h.type===Jo;e?(g&&!u&&t+1<p&&fs(d[t+1]).type===Jo&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,mi(r,1)||ii()),n(null,h,r,null,o,s,si(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&ci(f)&&f.data===`]`?a(t.anchor=f):(ii(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(gi(e,t)||ii(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,si(d),s),r&&(r.vnode.el=t.el,ro(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&ci(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var ui=new Set([`src`,`srcset`,`href`,`poster`]);function di(e,t,n){return ui.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var fi=`data-allow-mismatch`,pi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function mi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(fi);)e=e.parentElement;return hi(e&&e.getAttribute(fi),t)}function hi(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(pi[t])}}function gi(e,t){return mi(e.parentElement,1)||_i(e)||vi(t)}function _i(e){return e.nodeType===1&&hi(e.getAttribute(fi),1)}function vi({props:e}){let t=e&&e[fi];return typeof t==`string`&&hi(t,1)}var yi=de().requestIdleCallback||(e=>setTimeout(e,1)),bi=de().cancelIdleCallback||(e=>clearTimeout(e)),xi=(e=1e4)=>t=>{let n=yi(t,{timeout:e});return()=>bi(n)};function Si(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Ci=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Si(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},wi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Ti=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Ei(e,t){if(ci(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(ci(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Di=e=>!!e.type.__asyncLoader;function Oi(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return L({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Ei(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=ys;if(Zr(e),u)return()=>ki(u,e);let t=t=>{l=null,Rn(t,e,13,!r)};if(s&&e.suspense||Es)return p().then(t=>()=>ki(t,e)).catch(e=>(t(e),()=>r?G(r,{error:e}):null));let a=N(!1),c=N(),d=N(!!i),f,m;return Ki(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Ai(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return ki(u,e);if(c.value&&r)return G(r,{error:c.value});if(n&&!d Line truncated
`))),e[Dl]=wl(i);let a=r||i.props&&i.props.type===`number`;Gc(e,t?`change`:`input`,t=>{t.target.composing||e[Dl](kl(e.value,n,a))}),(n||a)&&Gc(e,`change`,()=>{e.value=kl(e.value,n,a)}),t||(Gc(e,`compositionstart`,Tl),Gc(e,`compositionend`,El),Gc(e,`change`,El))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Ol];delete e[Ol],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Dl](kl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Dl]=wl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?ce(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},jl={deep:!0,created(e,t,n){e[Dl]=wl(n),Gc(e,`change`,()=>{let t=e._modelValue,n=Il(e),r=e.checked,i=e[Dl];if(p(t)){let e=De(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(Ll(e,r))})},mounted:Ml,beforeUpdate(e,t,n){e[Dl]=wl(n),Ml(e,t,n)}};function Ml(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=De(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=Ee(t,Ll(e,!0))}e.checked!==i&&(e.checked=i)}var Nl={created(e,{value:t},n){e.checked=Ee(t,n.props.value),e[Dl]=wl(n),Gc(e,`change`,()=>{e[Dl](Il(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Dl]=wl(r),t!==n&&(e.checked=Ee(t,r.props.value))}},Pl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Gc(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?ce(Il(e)):Il(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Dl](i)}finally{qn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Dl]=wl(r)},mounted(e,{value:t}){Fl(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Dl]=wl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!pee(t,n[1],n[0]))&&Fl(e,t)}};function pee(e,t,n){if(!n||p(e))return Ee(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function Fl(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=Il(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):De(t,o)>-1}else a.selected=t.has(o)}else if(Ee(Il(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Il(e){return`_value`in e?e._value:e.value}function Ll(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Rl={created(e,t,n){Bl(e,t,n,null,`created`)},mounted(e,t,n){Bl(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){Bl(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){Bl(e,t,n,r,`updated`)}};function zl(e,t){switch(e){case`SELECT`:return Pl;case`TEXTAREA`:return Al;default:switch(t){case`checkbox`:return jl;case`radio`:return Nl;default:return Al}}}function Bl(e,t,n,r,i){let a=zl(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function mee(){Al.getSSRProps=({value:e})=>({value:e}),Nl.getSSRProps=({value:e},t)=>{if(t.props&&Ee(t.props.value,e))return{checked:!0}},jl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&De(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},Rl.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=zl(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var hee=[`ctrl`,`shift`,`alt`,`meta`],gee={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>hee.some(n=>e[`${n}Key`]&&!t.includes(n))},Vl=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=gee[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},_ee={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Hl=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=re(n.key);if(t.some(e=>e===r||_ee[e]===r))return e(n)}))},Ul=l({patchProp:rl},rc),Wl,Gl=!1;function Kl(){return Wl||=wo(Ul)}function ql(){return Wl=Gl?Wl:To(Ul),Gl=!0,Wl}var Jl=((...e)=>{Kl().render(...e)}),Yl=((...e)=>{ql().hydrate(...e)}),Xl=((...e)=>{let t=Kl().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=$l(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Ql(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a}, Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Lp;function Rp(e){Lp=e}var zp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Bp(e){let t=e instanceof zp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Vp(e,t){let n=await fetch(e,t);if(Lp?.(n.status===401),!n.ok)throw new zp(await Ip(n),n.status);return n}async function Hp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Pp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Vp(e,s);return a?await c.json():void 0}var Z={health:()=>Hp(`/health/detailed`),services:()=>Hp(`/api/services`),policies:()=>Hp(`/api/access/policies`),putPolicy:e=>Hp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Hp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>Hp(`/api/orgs`),org:e=>Hp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Hp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Hp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>Hp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>Hp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Hp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+Fp({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Hp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>Hp(`/api/summary`),tasks:()=>Hp(`/api/tasks`),taskPage:async e=>{let t=await Vp(`/api/tasks`+Fp(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(Pp)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Hp(`/api/task-meta`),task:e=>Hp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Hp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/changes`+Fp(t)),taskDebug:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/debug`+Fp(t)),taskAction:(e,t,n)=>Hp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Hp(`/api/setup`),capabilities:()=>Hp(`/api/capabilities`),workflows:()=>Hp(`/api/workflows`),workflowEnabled:(e,t)=>Hp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Hp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Hp(`/api/skills`),channels:()=>Hp(`/api/channels`),curators:()=>Hp(`/api/curators`),channelReload:e=>Hp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Hp(`/api/config`),logs:e=>Hp(`/api/logs`+Fp(e)),taskLogs:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/logs`+Fp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Hp(`/api/version`),updateSnapshot:()=>Hp(`/api/chat/update`),updateInstall:e=>Hp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Hp(`/api/captures`+Fp({limit:e})),eventTypes:()=>Hp(`/api/event-types`),eventTypeCreate:e=>Hp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Hp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Hp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Hp(`/api/mappings`),mappingCreate:e=>Hp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Hp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Hp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Hp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Hp(`/api/bindings`),dispatches:(e,t)=>Hp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>Hp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Hp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Hp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>Hp(`/api/harness/bindings`),sources:()=>Hp(`/api/sources`),sourceCreate:e=>Hp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Hp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Hp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceSecret:e=>Hp Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Lp;function Rp(e){Lp=e}var zp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Bp(e){let t=e instanceof zp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Vp(e,t){let n=await fetch(e,t);if(Lp?.(n.status===401),!n.ok)throw new zp(await Ip(n),n.status);return n}async function Hp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Pp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Vp(e,s);return a?await c.json():void 0}var Z={health:()=>Hp(`/health/detailed`),services:()=>Hp(`/api/services`),policies:()=>Hp(`/api/access/policies`),putPolicy:e=>Hp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Hp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>Hp(`/api/orgs`),org:e=>Hp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Hp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Hp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>Hp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>Hp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Hp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+Fp({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Hp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>Hp(`/api/summary`),tasks:()=>Hp(`/api/tasks`),taskPage:async e=>{let t=await Vp(`/api/tasks`+Fp(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(Pp)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Hp(`/api/task-meta`),task:e=>Hp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Hp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/changes`+Fp(t)),taskDebug:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/debug`+Fp(t)),taskAction:(e,t,n)=>Hp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Hp(`/api/setup`),capabilities:()=>Hp(`/api/capabilities`),workflows:()=>Hp(`/api/workflows`),workflowEnabled:(e,t)=>Hp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Hp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Hp(`/api/skills`),channels:()=>Hp(`/api/channels`),curators:()=>Hp(`/api/curators`),channelReload:e=>Hp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Hp(`/api/config`),logs:e=>Hp(`/api/logs`+Fp(e)),taskLogs:(e,t)=>Hp(`/api/tasks/${encodeURIComponent(e)}/logs`+Fp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Hp(`/api/version`),updateSnapshot:()=>Hp(`/api/chat/update`),updateInstall:e=>Hp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Hp(`/api/captures`+Fp({limit:e})),eventTypes:()=>Hp(`/api/event-types`),eventTypeCreate:e=>Hp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Hp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Hp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Hp(`/api/mappings`),mappingCreate:e=>Hp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Hp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Hp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Hp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Hp(`/api/bindings`),dispatches:(e,t)=>Hp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>Hp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Hp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Hp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>Hp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>Hp(`/api/harness/bindings`),sources:()=>Hp(`/api/sources`),sourceCreate:e=>Hp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Hp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Hp(`/api/sources/${encodeURIComponent(e)}/approve-unsigned`,{method:`POST`}),sourceName:(e,t)=> Line truncated
`);u=r.pop()||``;for(let e of r){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(im.value=n.session_id),n.type===`delta`&&(o+=n.text,lm.value=lm.value?{...lm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],lm.value=lm.value?{...lm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);am.value=[...am.value,{from:`assistant`,text:o,tool_calls:a}],lm.value=null,sm.value=`Ready`,await wm()}catch(e){let t=e;t.name===`AbortError`&&!c?(lm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},sm.value=`Stopped`):(lm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?$p(r):void 0,isRetry:i},sm.value=`Error — retry available`)}finally{clearTimeout(l),Sm=null,cm.value=!1}}function Cee(){sm.value=`Stopping…`,im.value&&Z.chatCancel(im.value).catch(()=>{}),Cm()}function wee(){Hi(()=>{wm().catch(e=>{sm.value=e.message||`Chat unavailable`})}),Ki(()=>{Cm()})}var Tee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Eee=L({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return X(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(V(),H(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":P(tm),onClick:i[0]||=e=>n(`toggle`)},[W(`span`,{"aria-hidden":`true`,class:j(r(!e.open))},[G(P(Sd),{size:22})],2),W(`span`,{"aria-hidden":`true`,class:j(r(e.open))},[G(P(Qd),{size:22})],2)],8,Tee))}});function Nm(e){return typeof e==`string`?`'${e}'`:new Oee().serialize(e)}var Dee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Pm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Dee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Fm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Pm[n]?Pm[n]:n+128,s=a<128&&Pm[a]?Pm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Oee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Fm(e,t):n===`number`&&r===`number`?e-t:Fm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Fm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`FloatLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(im.value=n.session_id),n.type===`delta`&&(o+=n.text,lm.value=lm.value?{...lm.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],lm.value=lm.value?{...lm.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);am.value=[...am.value,{from:`assistant`,text:o,tool_calls:a}],lm.value=null,sm.value=`Ready`,await wm()}catch(e){let t=e;t.name===`AbortError`&&!c?(lm.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},sm.value=`Stopped`):(lm.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?$p(r):void 0,isRetry:i},sm.value=`Error — retry available`)}finally{clearTimeout(l),Sm=null,cm.value=!1}}function wee(){sm.value=`Stopping…`,im.value&&Z.chatCancel(im.value).catch(()=>{}),Cm()}function Tee(){Hi(()=>{wm().catch(e=>{sm.value=e.message||`Chat unavailable`})}),Ki(()=>{Cm()})}var Eee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Dee=L({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return X(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(V(),H(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":P(tm),onClick:i[0]||=e=>n(`toggle`)},[W(`span`,{"aria-hidden":`true`,class:j(r(!e.open))},[G(P(Sd),{size:22})],2),W(`span`,{"aria-hidden":`true`,class:j(r(e.open))},[G(P(Qd),{size:22})],2)],8,Eee))}});function Mm(e){return typeof e==`string`?`'${e}'`:new kee().serialize(e)}var Oee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Nm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Oee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Pm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Nm[n]?Nm[n]:n+128,s=a<128&&Nm[a]?Nm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var kee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Pm(e,t):n===`number`&&r===`number`?e-t:Pm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Pm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`FloatLine truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?Bs(t.default({present:o.value})[0],{ref:e=>{let t=ch(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Eg=L({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=wh(n.default()),r=e.findIndex(e=>e.type!==Yo);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?J(t,i.props):t,o=us({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Dg=[`area`,`img`,`input`],Og=L({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Dg.includes(r)?()=>Bs(r,t):r===`template`?()=>Bs(Eg,t,{default:n.default}):()=>Bs(e.as,t,{default:n.default})}});function kg(){let e=N();return{primitiveElement:e,currentElement:Y(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:ch(e))}}var[Ag,jg]=Bm(`CollapsibleRoot`),Mg=L({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Ch(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=vn(r);return jg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Q(),(e,t)=>(V(),U(P(Og),{as:e.as,"as-child":r.asChild,"data-state":P(i)?`open`:`closed`,"data-disabled":P(a)?``:void 0},{default:F(()=>[z(e.$slots,`default`,{open:P(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Ng=L({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=Ag();i.contentId||=hg(void 0,`reka-collapsible-content`);let a=N(),{forwardRef:o,currentElement:s}=Q(),c=N(0),l=N(0),u=Y(()=>i.open.value),d=N(u.value),f=N();I(()=>[u.value,a.value?.present],async()=>{await qn();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=Y(()=>d.value&&i.open.value);return Hi(()=>{requestAnimationFrame(()=>{d.value=!1})}),lh(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(V(),U(P(Tg),{ref_key:`presentRef`,ref:a,present:e.forceMount||P(i).open.value,"force-mount":!0},{default:F(({present:t})=>[G(P(Og),J(e.$attrs,{id:P(i).contentId,ref:P(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:P(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:P(i).open.value?`open`:`closed`,"data-disabled":P(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:F(()=>[!P(i).unmountOnHide.value||t?z(e.$slots,`default`,{key:0}):q(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),Pg=L({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Q();let n=Ag();return(e,r)=>(V(),U(P(Og),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":P(n).contentId,"aria-expanded":P(n).open.value,"data-state":P(n).open.value?`open`:`closed`,"data-disabled":P(n).disabled?.value?``:void 0,disabled:P(n).disabled?.value,onClick:P(n).onOpenToggle},{default:F(()=>[z(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Fg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Ig({type:e,defaultValue:t,modelValue:n}){return e||Fg({type:e,defaultValue:t,modelValue:n})}function Lg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Rg(e,t){let n=Y(()=>Ig(e)),r=Ch(e,`modelValue`,t,{defaultValue:Lg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Im(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Wm(t,e)){let n=t.findIndex(t=>Im(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:Y(()=>n.value===`single`)}}var[zg,Bg]=Bm(`AccordionRoot`),Vg=L({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
`))}return()=>i.value||r.value||o.value?Bs(t.default({present:o.value})[0],{ref:e=>{let t=sh(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),Tg=L({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Ch(n.default()),r=e.findIndex(e=>e.type!==Yo);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?J(t,i.props):t,o=us({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Eg=[`area`,`img`,`input`],Dg=L({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Eg.includes(r)?()=>Bs(r,t):r===`template`?()=>Bs(Tg,t,{default:n.default}):()=>Bs(e.as,t,{default:n.default})}});function Og(){let e=N();return{primitiveElement:e,currentElement:Y(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:sh(e))}}var[kg,Ag]=zm(`CollapsibleRoot`),jg=L({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=Sh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=vn(r);return Ag({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Q(),(e,t)=>(V(),U(P(Dg),{as:e.as,"as-child":r.asChild,"data-state":P(i)?`open`:`closed`,"data-disabled":P(a)?``:void 0},{default:F(()=>[z(e.$slots,`default`,{open:P(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Mg=L({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=kg();i.contentId||=mg(void 0,`reka-collapsible-content`);let a=N(),{forwardRef:o,currentElement:s}=Q(),c=N(0),l=N(0),u=Y(()=>i.open.value),d=N(u.value),f=N();I(()=>[u.value,a.value?.present],async()=>{await qn();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=Y(()=>d.value&&i.open.value);return Hi(()=>{requestAnimationFrame(()=>{d.value=!1})}),ch(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(V(),U(P(wg),{ref_key:`presentRef`,ref:a,present:e.forceMount||P(i).open.value,"force-mount":!0},{default:F(({present:t})=>[G(P(Dg),J(e.$attrs,{id:P(i).contentId,ref:P(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:P(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:P(i).open.value?`open`:`closed`,"data-disabled":P(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:F(()=>[!P(i).unmountOnHide.value||t?z(e.$slots,`default`,{key:0}):q(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),Ng=L({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Q();let n=kg();return(e,r)=>(V(),U(P(Dg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":P(n).contentId,"aria-expanded":P(n).open.value,"data-state":P(n).open.value?`open`:`closed`,"data-disabled":P(n).disabled?.value?``:void 0,disabled:P(n).disabled?.value,onClick:P(n).onOpenToggle},{default:F(()=>[z(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Pg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Fg({type:e,defaultValue:t,modelValue:n}){return e||Pg({type:e,defaultValue:t,modelValue:n})}function Ig({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Lg(e,t){let n=Y(()=>Fg(e)),r=Sh(e,`modelValue`,t,{defaultValue:Ig(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Fm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Um(t,e)){let n=t.findIndex(t=>Fm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:Y(()=>n.value===`single`)}}var[Rg,zg]=zm(`AccordionRoot`),Bg=L({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
- a positive number
- less than the value passed to \`max\` (or ${yS} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${vS} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function wS(e){return SS(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 \`${yS}\`.`),yS)}var TS=L({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:yS},getValueLabel:{type:Function,required:!1,default:(e,t)=>SS(e)?`${Math.round(e/t*yS)}%`: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;Q();let i=Ch(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Ch(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=CS(e,n.max);t!==e&&(await qn(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=wS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=Y(()=>Um(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return xS({modelValue:i,max:a,progressState:o}),(e,t)=>(V(),U(P(Og),{"as-child":e.asChild,as:e.as,"aria-valuemax":P(a),"aria-valuemin":0,"aria-valuenow":SS(P(i))?P(i):void 0,"aria-valuetext":e.getValueText?.(P(i),P(a)),"aria-label":e.getValueLabel(P(i),P(a)),role:`progressbar`,"data-state":o.value,"data-value":P(i)??void 0,"data-max":P(a)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),ES=L({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=bS();return Q(),(e,r)=>(V(),U(P(Og),J(t,{"data-state":P(n).progressState.value,"data-value":P(n).modelValue?.value??void 0,"data-max":P(n).max.value}),{default:F(()=>[z(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),DS=`radio.select`;function OS(e,t,n){Hm(DS,n,{originalEvent:e,value:t})}var kS=L({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=Ch(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=vn(n),{forwardRef:o,currentElement:s}=Q(),c=qh(s),l=Xh(),u=Y(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||OS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(V(),H(B,null,[G(P(Og),J({id:e.id,ref:P(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":P(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":P(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:P(a),required:e.required,name:e.name},{...P(l),...e.$attrs},{onClick:Vl(d,[`stop`])}),{default:F(()=>[z(e.$slots,`default`,{checked:P(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),P(c)&&e.name?(V(),U(P(rv),J({key:0,type:`radio`,tabindex:`-1`,value:P(a),checked:!!P(i),name:e.name,disabled:e.disabled,required:e.required},P(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):q(`v-if`,!0)],64))}}),[AS,jS]=Bm(`RadioGroupRoot`),MS=L({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Q(),o=Ch(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=vn(n),p=Hh(f),m=qh(a);return jS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(V(),U(P(zb),{"as-child":``,orientation:P(l),dir:P(p),loop:P(c)},{default:F(()=>[G(P(Og),{ref:P(i),role:`radiogroup`,"data-disabled":P(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":P(l),"aria-required":P(d),dir:P(p)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(o)}),P(m)&&P(u)?(V(),U(P(rv),{key:0,required:P(d),disabled:P(s),value:P(o),name:P(u)},null,8,[`required`,`disabled`,`value`,`name`])):q(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[Lee,NS]=Bm(`RadioGroupItem`),PS=L({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nuLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:DE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>DE(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=kE(c),u=e+1<n.length?kE(n[e+1]):null;if(l&&u&&Bee(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=kE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>DE(e)),rows:r.map(e=>e.map(e=>DE(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:DE(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:DE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function kE(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 Bee(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Vee={class:`[overflow-wrap:anywhere]`},Hee={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Uee={class:`font-mono text-[0.85em]`},Wee={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Gee={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Kee={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},qee={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Jee={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Yee={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Xee={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Zee={key:8,class:`mb-2.5 last:mb-0`},Qee=L({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=Y(()=>OE(t.text));return(e,t)=>(V(),H(`div`,Vee,[(V(!0),H(B,null,R(n.value,(e,t)=>(V(),H(B,{key:t},[e.kind===`pre`?(V(),H(`pre`,Hee,[W(`code`,Uee,M(e.code),1)])):e.kind===`table`?(V(),H(`table`,Wee,[W(`thead`,null,[W(`tr`,null,[(V(!0),H(B,null,R(e.head,(e,t)=>(V(),H(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[G(TE,{inline:e},null,8,[`inline`])]))),128))])]),W(`tbody`,null,[(V(!0),H(B,null,R(e.rows,(e,t)=>(V(),H(`tr`,{key:t},[(V(!0),H(B,null,R(e,(e,t)=>(V(),H(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[G(TE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(V(),H(`blockquote`,Gee,[G(TE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(V(),H(`h1`,Kee,[G(TE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(V(),H(`h2`,qee,[G(TE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(V(),H(`h3`,Jee,[G(TE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(V(),H(`ul`,Yee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(TE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(V(),H(`ol`,Xee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(TE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(V(),H(`p`,Zee,[G(TE,{inline:e.inline},null,8,[`inline`])])):q(``,!0)],64))),128))]))}}),$ee={class:`truncate`},ete=L({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=$i(`RouterLink`);return V(),U(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:F(()=>[G(P(Xu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),W(`span`,$ee,M(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),tte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},nte={class:`font-semibold text-foreground`},rte={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},ite=L({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=Y(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=Y(()=>t.tool.parameters||t.tool.Parameters||``),i=Y(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=Y(()=>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?(V(),U(ete,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(V(),H(`div`,tte,[G(P(Zd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),W(`span`,nte,M(n.value),1),r.value?(V(),H(`code`,rte,M(r.value),1)):q(``,!0),W(`span`,{class:j(P(X)(`text-fg-muted`,i.value&&`text-danger`))},M(a.value),3)]))}}),ate={key:0,class:`mb-2 grid gap-0.5 text-xs`},ote={key:1,class:`mb-2 flex flex-wrap gap-1.5`},ste={key:3,class:`whitespace-pre-wrap`},AE=L({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(V(),H(`div`,{class:j([`flex`,e.assistant?`justify-start`:`justify-end`])},[W(`div`,{class:j(P(X)(`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?(V(),H(`div`,ate,[(V(!0),H(B,null,R(e.tools,(t,n)=>(V(),U(ite,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):q(``,!0),e.media.length?(V(),H(`div`,ote,[(V(!0),H(B,null,R(e.media,(e,t)=>(V(),U(vE,{key:t,attachment:e},null,8,[`attachment`]))),128))])):q(``,!0),e.assistant?(V(),U(Qee,{key:2,text:e.text},null,8,[`text`])):(V(),H(`div`,ste,M(e.text),1)),z(t.$slots,`default`)],2)],2))}}),cte={class:`w-full self-center justify-self-center py-6 text-center`},lte={class:`grid gap-2`},ute=[`onCliLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>Tj?`${n.slice(0,Tj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var Dj=[`title`],Oj=L({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>ZA(n.event)),a=Y(()=>Ej(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=Y(()=>n.event.at?aA(n.event.at):`—`);return(e,t)=>(V(),U(P(Sj),{class:j(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:[Hl(Vl(o,[`prevent`]),[`enter`]),Hl(Vl(o,[`prevent`]),[`space`])]},{default:F(()=>[G(P(xj),{class:`font-medium`},{default:F(()=>[K(M(n.event.kind||n.event.type||`event`),1)]),_:1}),G(P(xj),{class:`font-mono`},{default:F(()=>[K(M(i.value>0?`#${i.value}`:`—`),1)]),_:1}),G(P(xj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},M(a.value.text),9,Dj)]),_:1}),G(P(xj),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),kj=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function Aj(e){return(Number(e?.task_id)||0)>0}function jj(e,t){return t===`tasks`?Aj(e):t!==`system`||!Aj(e)}function Mj(e,t){return e.filter(e=>jj(e,t))}function Nj(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function Pj(e,t){return`${e}:${t??0}`}function Fj(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=Pj(Ej(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var Ij={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Lj={class:`max-h-[28rem] overflow-y-auto`},Rj=[`aria-expanded`,`aria-label`,`onClick`],zj=[`title`],Bj=L({__name:`LiveActivityCard`,setup(e){let t=GE(),{activity:n,streamKind:r,streamState:i}=Fu(sk()),a=N(`all`),o=Y(()=>Mj(n.value,a.value)),s=Y(()=>Nj(o.value.length,a.value)),c=Jt(new Set),l=Y(()=>Fj(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return Ej(e.representative)}function p(e){return e.representative.at?aA(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(V(),U(P(Qk),null,{default:F(()=>[G(P(rA),null,{default:F(()=>[G(P(iA),null,{default:F(()=>[...t[1]||=[K(`Live activity`,-1)]]),_:1}),G(P($k),{class:`flex items-center gap-2`},{default:F(()=>[G(P(_j),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:P(kj)},null,8,[`modelValue`,`options`]),G(P(Yk),{variant:P(r)},{default:F(()=>[K(M(P(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),G(P(eA),null,{default:F(()=>[W(`div`,Ij,[W(`div`,Lj,[G(P(yj),null,{default:F(()=>[G(P(wj),{class:`sticky top-0 z-10 bg-card`},{default:F(()=>[G(P(Sj),null,{default:F(()=>[G(P(Cj),null,{default:F(()=>[...t[2]||=[K(`Event`,-1)]]),_:1}),G(P(Cj),null,{default:F(()=>[...t[3]||=[K(`Task`,-1)]]),_:1}),G(P(Cj),null,{default:F(()=>[...t[4]||=[K(`Detail`,-1)]]),_:1}),G(P(Cj),null,{default:F(()=>[...t[5]||=[K(`When`,-1)]]),_:1})]),_:1})]),_:1}),G(P(bj),null,{default:F(()=>[o.value.length?q(``,!0):(V(),U(P(Sj),{key:0},{default:F(()=>[G(P(xj),{colspan:`4`},{default:F(()=>[G(P(Vk),null,{default:F(()=>[G(P(Wk),null,{default:F(()=>[G(P(qk),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(V(!0),H(B,{key:1},R(l.value,e=>(V(),H(B,{key:e.key},[e.count===1?(V(),U(Oj,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(V(),H(B,{key:1},[G(P(Sj),{class:j(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Hl(Vl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Hl(Vl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:F(()=>[G(P(xj),{class:`font-medium`},{default:F(()=>[W(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Vl(t=>u(e.key),[`stop`])},[d(e)?(V(),U(P(rd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(V(),U(P(id),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),K(` `+M(e.label)+` `,1),G(P(Yk),{variant:`idle`},{default:F(()=>[K(`×`+M(e.count),1)]),_:2},1024)],8,Rj)]),_:2},1024),G(P(xj),{class:`font-mono`},{default:F(()=>[K(M(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),G(P(xj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},M(f(e).text),9,zj)]),_:2},1024),G(P(xj),null,{default:F(()=>[K(M(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(V(!0),H(B,{key:0},R(e.events,(t,n)=>(V(),U(Oj,{key:`${e.key}:${n}`,ev Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function sN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function cN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function lN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function uN(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var dN=N([]),fN=N([]),pN=N(!0),mN=N(null),hN=N(null),gN=N(!1),_N=N(null);async function vN(){try{let e=await Z.eventTypes();pN.value=e.enabled!==!1,dN.value=e.event_types||[],fN.value=e.proposals||[],mN.value=null}catch(e){mN.value=e.message||String(e)}}function yN(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function bN(e){_N.value=null,hN.value=e}function xN(e){let t=kN.value.find(t=>String(t.id)===e.sample_id);bN({mode:`proposal`,id:null,source:e.source,name:``,rule:yN(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function SN(e=``){bN({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function CN(e){bN({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:yN(e.rule),headersText:``,body:``,exampleHeaders:{}})}function wN(){hN.value=null}async function TN(){let e=hN.value;if(e){gN.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:uN(e.rule)});else{let t=e.mode===`paste`?oN(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:uN(e.rule),example:{headers:t,body:e.body}})}hN.value=null,await vN()}catch(e){_N.value=e.message||String(e)}finally{gN.value=!1}}}var EN=N(null);async function DN(){let e=EN.value;if(EN.value=null,e)try{await Z.eventTypeDelete(e.id),await vN()}catch(e){mN.value=e.message||String(e)}}var ON=100,kN=N([]),AN=N(!0),jN=N(null),MN=N(!0),NN=N(null);async function PN(){try{let e=await Z.captures(ON);AN.value=e.enabled!==!1,kN.value=e.captures||[],jN.value=null}catch(e){jN.value=e.message||String(e)}finally{MN.value=!1}}function FN(e){let t=kN.value.find(t=>t.id===e);return t&&(NN.value=t),!!t}function IN(){kN.value.length&&(NN.value=kN.value[0])}function LN(){ck(`captures`,()=>{PN(),vN()})}var RN=`archie.theme`,zN=`archie.density`,BN=`archie.motion`,VN=`archie.tooltips`;function HN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function UN(e,t){try{localStorage.setItem(e,t)}catch{}}function WN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var GN=Pu(`appearance`,()=>{let e=N(HN(RN,[`system`,`dark`,`light`],`dark`)),t=N(HN(zN,[`comfortable`,`compact`],`comfortable`)),n=N(HN(BN,[`system`,`reduced`],`system`)),r=N(HN(VN,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=WN(e.value)}function o(t){e.value=t,a(),UN(RN,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,UN(zN,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,UN(BN,e)}function l(e){r.value=e,UN(VN,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),KN=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Yh(n,t),{tooltipsEnabled:i}=Fu(GN());return(e,t)=>(V(),U(P(YC),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(ls(t)))]),_:3},16,[`disabled`]))}}),qN=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=Yh(hw(n,`class`),r);return(e,t)=>(V(),U(P($C),null,{default:F( Line truncated
Defaulting to \`null\`.`),null)}function CS(e){return xS(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 \`${vS}\`.`),vS)}var wS=L({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:vS},getValueLabel:{type:Function,required:!1,default:(e,t)=>xS(e)?`${Math.round(e/t*vS)}%`: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;Q();let i=Sh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Sh(n,`max`,r,{passive:n.max===void 0});I(()=>i.value,async e=>{let t=SS(e,n.max);t!==e&&(await qn(),i.value=t)},{immediate:!0}),I(()=>n.max,e=>{let t=CS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=Y(()=>Hm(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return bS({modelValue:i,max:a,progressState:o}),(e,t)=>(V(),U(P(Dg),{"as-child":e.asChild,as:e.as,"aria-valuemax":P(a),"aria-valuemin":0,"aria-valuenow":xS(P(i))?P(i):void 0,"aria-valuetext":e.getValueText?.(P(i),P(a)),"aria-label":e.getValueLabel(P(i),P(a)),role:`progressbar`,"data-state":o.value,"data-value":P(i)??void 0,"data-max":P(a)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),TS=L({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=yS();return Q(),(e,r)=>(V(),U(P(Dg),J(t,{"data-state":P(n).progressState.value,"data-value":P(n).modelValue?.value??void 0,"data-max":P(n).max.value}),{default:F(()=>[z(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),ES=`radio.select`;function DS(e,t,n){Vm(ES,n,{originalEvent:e,value:t})}var OS=L({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=Sh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=vn(n),{forwardRef:o,currentElement:s}=Q(),c=Kh(s),l=Yh(),u=Y(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||DS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(V(),H(B,null,[G(P(Dg),J({id:e.id,ref:P(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":P(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":P(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:P(a),required:e.required,name:e.name},{...P(l),...e.$attrs},{onClick:Vl(d,[`stop`])}),{default:F(()=>[z(e.$slots,`default`,{checked:P(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),P(c)&&e.name?(V(),U(P(nv),J({key:0,type:`radio`,tabindex:`-1`,value:P(a),checked:!!P(i),name:e.name,disabled:e.disabled,required:e.required},P(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):q(`v-if`,!0)],64))}}),[kS,AS]=zm(`RadioGroupRoot`),jS=L({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Q(),o=Sh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=vn(n),p=Vh(f),m=Kh(a);return AS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(V(),U(P(Rb),{"as-child":``,orientation:P(l),dir:P(p),loop:P(c)},{default:F(()=>[G(P(Dg),{ref:P(i),role:`radiogroup`,"data-disabled":P(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":P(l),"aria-required":P(d),dir:P(p)},{default:F(()=>[z(e.$slots,`default`,{modelValue:P(o)}),P(m)&&P(u)?(V(),U(P(nv),{key:0,required:P(d),disabled:P(s),value:P(o),name:P(u)},null,8,[`required`,`disabled`,`value`,`name`])):q(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[Ree,MS]=zm(`RadioGroupItem`),NS=L({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nuLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:EE(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>EE(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=OE(c),u=e+1<n.length?OE(n[e+1]):null;if(l&&u&&Vee(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=OE(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>EE(e)),rows:r.map(e=>e.map(e=>EE(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:EE(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:EE(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function OE(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 Vee(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Hee={class:`[overflow-wrap:anywhere]`},Uee={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Wee={class:`font-mono text-[0.85em]`},Gee={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Kee={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},qee={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Jee={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Yee={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Xee={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Zee={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Qee={key:8,class:`mb-2.5 last:mb-0`},$ee=L({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=Y(()=>DE(t.text));return(e,t)=>(V(),H(`div`,Hee,[(V(!0),H(B,null,R(n.value,(e,t)=>(V(),H(B,{key:t},[e.kind===`pre`?(V(),H(`pre`,Uee,[W(`code`,Wee,M(e.code),1)])):e.kind===`table`?(V(),H(`table`,Gee,[W(`thead`,null,[W(`tr`,null,[(V(!0),H(B,null,R(e.head,(e,t)=>(V(),H(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[G(wE,{inline:e},null,8,[`inline`])]))),128))])]),W(`tbody`,null,[(V(!0),H(B,null,R(e.rows,(e,t)=>(V(),H(`tr`,{key:t},[(V(!0),H(B,null,R(e,(e,t)=>(V(),H(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[G(wE,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(V(),H(`blockquote`,Kee,[G(wE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(V(),H(`h1`,qee,[G(wE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(V(),H(`h2`,Jee,[G(wE,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(V(),H(`h3`,Yee,[G(wE,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(V(),H(`ul`,Xee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(wE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(V(),H(`ol`,Zee,[(V(!0),H(B,null,R(e.items,(e,t)=>(V(),H(`li`,{key:t},[G(wE,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(V(),H(`p`,Qee,[G(wE,{inline:e.inline},null,8,[`inline`])])):q(``,!0)],64))),128))]))}}),ete={class:`truncate`},tte=L({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=$i(`RouterLink`);return V(),U(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:F(()=>[G(P(Xu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),W(`span`,ete,M(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),nte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},rte={class:`font-semibold text-foreground`},ite={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},ate=L({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=Y(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=Y(()=>t.tool.parameters||t.tool.Parameters||``),i=Y(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=Y(()=>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?(V(),U(tte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(V(),H(`div`,nte,[G(P(Zd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),W(`span`,rte,M(n.value),1),r.value?(V(),H(`code`,ite,M(r.value),1)):q(``,!0),W(`span`,{class:j(P(X)(`text-fg-muted`,i.value&&`text-danger`))},M(a.value),3)]))}}),ote={key:0,class:`mb-2 grid gap-0.5 text-xs`},ste={key:1,class:`mb-2 flex flex-wrap gap-1.5`},cte={key:3,class:`whitespace-pre-wrap`},kE=L({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(V(),H(`div`,{class:j([`flex`,e.assistant?`justify-start`:`justify-end`])},[W(`div`,{class:j(P(X)(`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?(V(),H(`div`,ote,[(V(!0),H(B,null,R(e.tools,(t,n)=>(V(),U(ate,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):q(``,!0),e.media.length?(V(),H(`div`,ste,[(V(!0),H(B,null,R(e.media,(e,t)=>(V(),U(_E,{key:t,attachment:e},null,8,[`attachment`]))),128))])):q(``,!0),e.assistant?(V(),U($ee,{key:2,text:e.text},null,8,[`text`])):(V(),H(`div`,cte,M(e.text),1)),z(t.$slots,`default`)],2)],2))}}),lte={class:`w-full self-center justify-self-center py-6 text-center`},ute={class:`grid gap-2`},dte=[`onCliLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>wj?`${n.slice(0,wj).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var Ej=[`title`],Dj=L({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>XA(n.event)),a=Y(()=>Tj(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=Y(()=>n.event.at?iA(n.event.at):`—`);return(e,t)=>(V(),U(P(xj),{class:j(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:[Hl(Vl(o,[`prevent`]),[`enter`]),Hl(Vl(o,[`prevent`]),[`space`])]},{default:F(()=>[G(P(bj),{class:`font-medium`},{default:F(()=>[K(M(n.event.kind||n.event.type||`event`),1)]),_:1}),G(P(bj),{class:`font-mono`},{default:F(()=>[K(M(i.value>0?`#${i.value}`:`—`),1)]),_:1}),G(P(bj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},M(a.value.text),9,Ej)]),_:1}),G(P(bj),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Oj=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function kj(e){return(Number(e?.task_id)||0)>0}function Aj(e,t){return t===`tasks`?kj(e):t!==`system`||!kj(e)}function jj(e,t){return e.filter(e=>Aj(e,t))}function Mj(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function Nj(e,t){return`${e}:${t??0}`}function Pj(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=Nj(Tj(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var Fj={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},Ij={class:`max-h-[28rem] overflow-y-auto`},Lj=[`aria-expanded`,`aria-label`,`onClick`],Rj=[`title`],zj=L({__name:`LiveActivityCard`,setup(e){let t=WE(),{activity:n,streamKind:r,streamState:i}=Fu(ok()),a=N(`all`),o=Y(()=>jj(n.value,a.value)),s=Y(()=>Mj(o.value.length,a.value)),c=Jt(new Set),l=Y(()=>Pj(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return Tj(e.representative)}function p(e){return e.representative.at?iA(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(V(),U(P(Zk),null,{default:F(()=>[G(P(nA),null,{default:F(()=>[G(P(rA),null,{default:F(()=>[...t[1]||=[K(`Live activity`,-1)]]),_:1}),G(P(Qk),{class:`flex items-center gap-2`},{default:F(()=>[G(P(gj),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:P(Oj)},null,8,[`modelValue`,`options`]),G(P(Jk),{variant:P(r)},{default:F(()=>[K(M(P(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),G(P($k),null,{default:F(()=>[W(`div`,Fj,[W(`div`,Ij,[G(P(vj),null,{default:F(()=>[G(P(Cj),{class:`sticky top-0 z-10 bg-card`},{default:F(()=>[G(P(xj),null,{default:F(()=>[G(P(Sj),null,{default:F(()=>[...t[2]||=[K(`Event`,-1)]]),_:1}),G(P(Sj),null,{default:F(()=>[...t[3]||=[K(`Task`,-1)]]),_:1}),G(P(Sj),null,{default:F(()=>[...t[4]||=[K(`Detail`,-1)]]),_:1}),G(P(Sj),null,{default:F(()=>[...t[5]||=[K(`When`,-1)]]),_:1})]),_:1})]),_:1}),G(P(yj),null,{default:F(()=>[o.value.length?q(``,!0):(V(),U(P(xj),{key:0},{default:F(()=>[G(P(bj),{colspan:`4`},{default:F(()=>[G(P(Bk),null,{default:F(()=>[G(P(Uk),null,{default:F(()=>[G(P(Kk),null,{default:F(()=>[K(M(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(V(!0),H(B,{key:1},R(l.value,e=>(V(),H(B,{key:e.key},[e.count===1?(V(),U(Dj,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(V(),H(B,{key:1},[G(P(xj),{class:j(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Hl(Vl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Hl(Vl(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:F(()=>[G(P(bj),{class:`font-medium`},{default:F(()=>[W(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Vl(t=>u(e.key),[`stop`])},[d(e)?(V(),U(P(rd),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(V(),U(P(id),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),K(` `+M(e.label)+` `,1),G(P(Jk),{variant:`idle`},{default:F(()=>[K(`×`+M(e.count),1)]),_:2},1024)],8,Lj)]),_:2},1024),G(P(bj),{class:`font-mono`},{default:F(()=>[K(M(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),G(P(bj),{class:`w-[55%] max-w-0`},{default:F(()=>[W(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},M(f(e).text),9,Rj)]),_:2},1024),G(P(bj),null,{default:F(()=>[K(M(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(V(!0),H(B,{key:0},R(e.events,(t,n)=>(V(),U(Dj,{key:`${e.key}:${n}`,ev Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function oN(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function sN(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function cN(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function lN(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var uN=N([]),dN=N([]),fN=N(!0),pN=N(null),mN=N(null),hN=N(!1),gN=N(null);async function _N(){try{let e=await Z.eventTypes();fN.value=e.enabled!==!1,uN.value=e.event_types||[],dN.value=e.proposals||[],pN.value=null}catch(e){pN.value=e.message||String(e)}}function vN(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function yN(e){gN.value=null,mN.value=e}function bN(e){let t=ON.value.find(t=>String(t.id)===e.sample_id);yN({mode:`proposal`,id:null,source:e.source,name:``,rule:vN(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function xN(e=``){yN({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function SN(e){yN({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:vN(e.rule),headersText:``,body:``,exampleHeaders:{}})}function CN(){mN.value=null}async function wN(){let e=mN.value;if(e){hN.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:lN(e.rule)});else{let t=e.mode===`paste`?aN(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:lN(e.rule),example:{headers:t,body:e.body}})}mN.value=null,await _N()}catch(e){gN.value=e.message||String(e)}finally{hN.value=!1}}}var TN=N(null);async function EN(){let e=TN.value;if(TN.value=null,e)try{await Z.eventTypeDelete(e.id),await _N()}catch(e){pN.value=e.message||String(e)}}var DN=100,ON=N([]),kN=N(!0),AN=N(null),jN=N(!0),MN=N(null);async function NN(){try{let e=await Z.captures(DN);kN.value=e.enabled!==!1,ON.value=e.captures||[],AN.value=null}catch(e){AN.value=e.message||String(e)}finally{jN.value=!1}}function PN(e){let t=ON.value.find(t=>t.id===e);return t&&(MN.value=t),!!t}function FN(){ON.value.length&&(MN.value=ON.value[0])}function IN(){sk(`captures`,()=>{NN(),_N()})}var LN=`archie.theme`,RN=`archie.density`,zN=`archie.motion`,BN=`archie.tooltips`;function VN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function HN(e,t){try{localStorage.setItem(e,t)}catch{}}function UN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var WN=Pu(`appearance`,()=>{let e=N(VN(LN,[`system`,`dark`,`light`],`dark`)),t=N(VN(RN,[`comfortable`,`compact`],`comfortable`)),n=N(VN(zN,[`system`,`reduced`],`system`)),r=N(VN(BN,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=UN(e.value)}function o(t){e.value=t,a(),HN(LN,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,HN(RN,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,HN(zN,e)}function l(e){r.value=e,HN(BN,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),GN=L({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Jh(n,t),{tooltipsEnabled:i}=Fu(WN());return(e,t)=>(V(),U(P(JC),J({"data-slot":`tooltip`},P(r),{disabled:n.disabled||!P(i)}),{default:F(t=>[z(e.$slots,`default`,ve(ls(t)))]),_:3},16,[`disabled`]))}}),KN=L({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=Jh(mw(n,`class`),r);return(e,t)=>(V(),U(P(QC),null,{default:F( Line truncated
`)}};cJ.defaultYaml={explicit:!1,version:`1.2`},cJ.defaultTags={"!!":`tag:yaml.org,2002:`};function lJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function uJ(e){let t=new Set;return tJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function dJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function fJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=uJ(e);let a=dJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(qq(t.node)||Yq(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function pJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=pJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=pJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=pJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=pJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function mJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>mJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Zq(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var hJ=class{constructor(e){Object.defineProperty(this,Hq,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Wq(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=mJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?pJ(i,{"":o},``,o):o}},gJ=class extends hJ{constructor(e){super(Iq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],tJ(e,{Node:(e,t)=>{(Uq(t)||Zq(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(mJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=_J(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(lJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function _J(e,t,n){if(Uq(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Yq(t)){let r=0;for(let i of t.items){let t=_J(e,i,n);t>r&&(r=t)}return r}if(Kq(t)){let r=_J(e,t.key,n),i=_J(e,t.value,n);return Math.max(r,i)}return 1}var vJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,yJ=class extends hJ{constructor(e){super(Bq),this.value=e}toJSON(e,t){return t?.keep?this.value:mJ(this.value,e,t)}toString(){return String(this.value)}};yJ.BLOCK_FOLDED=`BLOCK_FOLDED`,yJ.BLOCK_LITERAL=`BLOCK_LITERAL`,yJ.PLAIN=`PLAIN`,yJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,yJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var bJ=`tag:yaml.org,2002:`;function xJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function SJ(e,t,n){if(Wq(e)&&(e=e.contents),Xq(e))return e;if(Kq(e)){let t=n.schema[Rq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new gJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=bJ+t.slice(2));let l=xJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new yJ(e);return c&&(c.node=t),t Line truncated
`)?DJ(n,t):n.includes(`
`)?`
@@ -126,14 +126,14 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`).find(e=>e.trim())?.trim()}}function RZ(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(PZ)].map(e=>e[1]))]}function zZ(e){let t=TZ(e).toJS(),n=FZ(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=`start`;r.push({id:s,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let c=[s],l=1,u=new Map,d=e=>{let t=u.get(e)??0;return u.set(e,t+1),t},f=(e,t,n,i,s,c,l)=>{let u=FZ(e)?e:{},f=typeof u.type==`string`?u.type:``,p=FZ(u.settings)?u.settings:{},m=typeof u.id==`string`?u.id:``,h=`step-${t}`,g=s?`${s}/${m||f}`:m||f;r.push({id:h,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:m||t,title:m||NZ(f),type:f,detail:IZ(f,p),summary:LZ(p),when:typeof u.when==`string`?u.when:void 0,retry:FZ(u.retry)&&typeof u.retry.attempts==`number`?u.retry.attempts:void 0,continues:u.on_failure===`continue`,branch:s,path:l,stage:g,occurrence:d(g),...c?{resume:c}:{}}}),m&&a.set(m,h);for(let e of RZ(u.settings,u.when))o.push({from:e,to:h});return h},p=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){if(FZ(t)&&FZ(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i=[],a=0;n.forEach(([t,o],s)=>{let u=(s-(n.length-1)/2)*jZ,d=c,m=c;(Array.isArray(o)?o:[]).forEach((i,o)=>{let c=f(i,`${e+1}-${t}-${o+1}`,u,(l+o)*AZ,t,r,[`steps`,e,`parallel`,t,o]);p(d,c,d===m&&s===n.length-1?e-1:void 0),d=[c],a=Math.max(a,o+1)}),i.push(...d)}),c=i,l+=Math.max(a,1);continue}let n=f(t,String(e+1),0,l*AZ,void 0,void 0,[`steps`,e]);p(c,n,e-1),c=[n],l++}r.push({id:`add-end`,type:`add`,position:{x:104,y:l*AZ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``}}),p(c,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var BZ={agent:$u,command:Bd,repo:hd,gate:Ld,forge:Cd,human:qd,review:pd,workflow:Xd},VZ={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function HZ(e){return BZ[e.split(`.`)[0]]??Xd}function UZ(e){return Object.keys(VZ).map(t=>({title:VZ[t],icon:BZ[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function WZ(e,t){let n=TZ(e).getIn(t,!0);if(Gq(n))return n.toJSON()}function GZ(e,t,n){let r=TZ(e);return r.setIn(t,r.createNode(ZZ(n))),r.toString()}function KZ(e,t,n){let r=TZ(e),i=r.get(`steps`,!0);if(Jq(i)||(r.set(`steps`,r.createNode([])),i=r.get(`steps`,!0)),!Jq(i))return{source:e,path:[]};let a=Math.min(Math.max(t+1,0),i.items.length);return i.items.splice(a,0,r.createNode({type:n})),{source:r.toString(),path:[`steps`,a]}}function qZ(e,t){let n=TZ(e),r=n.getIn(t.slice(0,-1),!0),i=t.at(-1);if(!Jq(r)||typeof i!=`number`)return{source:e,path:t};let a=n.createNode(n.getIn(t));return Gq(a)&&a.delete(`id`),r.items.splice(i+1,0,a),{source:n.toString(),path:[...t.slice(0,-1),i+1]}}function JZ(e,t){let n=TZ(e);n.deleteIn(t);let r=t.slice(0,-1);if(r.length>2){let e=n.getIn(r,!0);Jq(e)&&e.items.length===0&&n.deleteIn(r)}return n.toString()}function YZ(e,t,n){let r=TZ(e),i=r.getIn(t.slice(0,-1),!0),a=t.at(-1);if(!Jq(i)||typeof a!=`number`)return{source:e,path:t};let o=a+n;if(o<0||o>=i.items.length)return{source:e,path:t};let[s]=i.items.splice(a,1);return i.items.splice(o,0,s),{source:r.toString(),path:[...t.slice(0,-1),o]}}function XZ(e,t){let n=TZ(e).toJS(),r=Array.isArray(n?.steps)?n.steps:[],i=typeof t[1]==`number`?t[1]:r.length,a=[],o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(typeof t.id==`string`&&a.push(t.id),typeof t.parallel==`object`&&t.parallel!==null)for(let e of Object.values(t.parallel))Array.isArray(e)&&e.forEach(o)};if(r.slice(0,i).forEach(o),t.length===5){let e=r[i]?.parallel?.[t[3]];Array.isArray(e)&&e.slice(0,t[4]).forEach(o)}return a}function ZZ(e){if(Array.isArray(e))return e.map(ZZ);if(typeof e!=`object`||!e)return e;let t={};for(let[n,r]of Object.entries(e)){if(r===void 0||r===``||r===null)continue;let e=ZZ(r);(typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length!==0)&&(t[n]=e)}return t}function QZ(e,t){let n=TZ(e).get(t,!0);return n&&typeof n==`object`&&`toJSON`in n?n.toJSON():TZ(e).get(t)}function $Z(e,t,n){let r=TZ(e),i=ZZ({[t]:n})[t];return i===void 0?r.delete(t):r.set(t,r.createNode(i)),r.toString()}function eQ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function tQ(e,t=[]){let n=TZ(e),r=n.errors[0];if(r)return{ok:!1,message:hQ(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!gQ(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};le Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:dQ(e)}))}var lQ=/^(\s*)(-\s+)?/,uQ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function dQ(e){let{code:t,comment:n}=fQ(e),r=pQ(t);return n&&r.push({text:n,kind:`comment`}),r}function fQ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function pQ(e){if(!e)return[];let t=[],n=lQ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=uQ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...mQ(i[4]??``)]):[...t,...mQ(r)]}function mQ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function hQ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function gQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _Q(e){return typeof e==`string`&&e.trim()!==``}var vQ={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},yQ={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},bQ={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},xQ={class:`min-w-0 flex-1`},SQ=[`value`,`placeholder`],CQ={class:`truncate font-mono text-[11px] text-fg-subtle`},wQ={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},TQ={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},EQ={key:1,class:`space-y-1.5`},DQ=[`title`],OQ=[`value`],kQ=[`value`],AQ={key:3,class:`flex flex-wrap items-center gap-1 pt-0.5`},jQ=[`onClick`],MQ=[`onClick`],NQ={key:2,class:`divide-y divide-border rounded-md border border-border`},PQ=[`title`],FQ=[`value`,`onChange`],IQ=[`value`],LQ=[`value`,`onInput`],RQ=[`value`,`onFocus`,`onInput`],zQ=[`title`],BQ={key:0,class:`text-xs text-danger`},VQ={class:`space-y-2`},HQ={class:`divide-y divide-border rounded-md border border-border`},UQ={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},WQ=[`value`],GQ={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},KQ=[`value`],qQ={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},JQ=[`value`],YQ={class:`flex items-center border-t border-border px-4 py-2.5`},XQ=L({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>WZ(n.yaml,n.path)??{}),a=Y(()=>typeof i.value.type==`string`?i.value.type:``),o=Y(()=>n.vocabulary.find(e=>e.name===a.value)),s=Y(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),c=Y(()=>XZ(n.yaml,n.path)),l=Y(()=>o.value?.settings&&i.value.settings?oQ(i.value.settings,o.value.settings,`settings`):``),u=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],d=/mission|body|detail|plan|rules/;function f(e,t){return t.type===`string`?t.enum?`select`:d.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let p=Y(()=>{let e=Object.entries(o.value?.settings?.properties??{}).map(([e,t])=>({key:e,schema:t,kind:f(e,t)})),t=e.filter(e=>u.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>u.indexOf(e.key)-u.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function m(e){let{id:t,type:i,...a}=e;r(`update:yaml`,GZ(n.yaml,n.path,{id:t,type:i,...a}))}function h(e,t){m({...i.value,[e]:t})}function g(e,t){m({...i.value,settings:{...s.value,[e]:t}})}let _=N(null);function v(e,t){let n=_.value??p.value.lead?.key;if(!n)return;let r=typeof s.value[n]==`string`?s.value[n]:``,i=`{{ steps.${e}.${t} }}`;g(n,r?`${r.trimEnd()} ${i}`:i)}let y=N({});function b(e,t){try{g(e,t.trim()?EZ(t):void 0),y.value={...y.value,[e]:``}}catch(t){y.value={...y.value,[e]:String(t.message).split(`
`)[0]}}}let x=e=>e===void 0?``:DZ(e).trimEnd(),S=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),C=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(V(),H(`aside`,vQ,[W(`header`,yQ,[W(`span`,bQ,[(V(),U(ta(P(HZ)(a.value)),{class:`size-4`}))]),W(`div`,xQ,[W(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:P(NZ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,SQ),W(`div`,CQ,M(a.value),1)]),G(P($),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:F(()=>[G(P(Qd))]),_:1})]),W(`div`,wQ,[l.value?(V(),H(`p`,TQ,M(l.value),1)):q(``,!0),p.value.lead?(V(),H(`section`,EQ,[W(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[K(M(S(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,DQ),p.value.lead.kind===`select`?(V(),H(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:C(p.value.lead.key),onChange:t[2]||=e=>g(p.value.lead.key,e.target.value||void 0)},[t[12]||=W(`option`,{value:``},`Default`,-1),(V(!0),H(B,null,R(p.value.lead.schema.enum,e=>(V(),H(`option`,{key:e,value:e},M(e),9,kQ))),128))],40,OQ)):p.value.lead.kind===`text`?(V(),U(P(cT),{key:1,"model-value":C(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>_.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>g(p.value.lead.key,String(e))},null,8,[`model-value`])):(V(),U(P(hO),{key:2,"model-value":C(p.value.lead.key),onFocus:t[5]||=e=>_.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>g(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(V(),H(`div`,AQ,[t[13]||=W(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(V(!0),H(B,null,R(c.value,e=>(V(),H(B,{key:e},[W(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>v(e,`summary`)},M(e),9,jQ),W(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>v(e,`result`)},M(e)+`.result`,9,MQ)],64))),128))])):q(``,!0)])):q(``,!0),p.value.compact.length?(V(),H(`section`,NQ,[(V(!0),H(B,null,R(p.value.compact,e=>(V(),H(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[W(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[K(M(S(e.key,e.schema))+` `,1),e.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,PQ),e.kind===`boolean`?(V(),U(P(BO),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>g(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(V(),H(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:C(e.key),onChange:t=>g(e.key,t.target.value||void 0)},[t[14]||=W(`option`,{value:``},`Default`,-1),(V(!0),H(B,null,R(e.schema.enum,e=>(V(),H(`option`,{key:e,value:e},M(e),9,IQ))),128))],40,FQ)):e.kind===`number`?(V(),H(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>g(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,LQ)):(V(),H(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:C(e.key),onFocus:t=>_.value=e.key,onInput:t=>g(e.key,t.target.value)},null,40,RQ))]))),128))])):q(``,!0),(V(!0),H(B,null,R(p.value.long,e=>(V(),H(`section`,{key:e.key,class:`space-y-1.5`},[W(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[K(M(S(e.key,e.schema))+` `,1),e.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,zQ),e.kind===`text`?(V(),U(P(cT),{key:0,"model-value":C(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>_.value=e.key,"onUpdate:modelValue":t=>g(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(V(),U(P(cT),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`)[0]}}}let x=e=>e===void 0?``:DZ(e).trimEnd(),S=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),C=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(V(),H(`aside`,vQ,[W(`header`,yQ,[W(`span`,bQ,[(V(),U(ta(P(HZ)(a.value)),{class:`size-4`}))]),W(`div`,xQ,[W(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:P(NZ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,SQ),W(`div`,CQ,M(a.value),1)]),G(P($),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:F(()=>[G(P(Qd))]),_:1})]),W(`div`,wQ,[l.value?(V(),H(`p`,TQ,M(l.value),1)):q(``,!0),p.value.lead?(V(),H(`section`,EQ,[W(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[K(M(S(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,DQ),p.value.lead.kind===`select`?(V(),H(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:C(p.value.lead.key),onChange:t[2]||=e=>g(p.value.lead.key,e.target.value||void 0)},[t[12]||=W(`option`,{value:``},`Default`,-1),(V(!0),H(B,null,R(p.value.lead.schema.enum,e=>(V(),H(`option`,{key:e,value:e},M(e),9,kQ))),128))],40,OQ)):p.value.lead.kind===`text`?(V(),U(P(sT),{key:1,"model-value":C(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>_.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>g(p.value.lead.key,String(e))},null,8,[`model-value`])):(V(),U(P(mO),{key:2,"model-value":C(p.value.lead.key),onFocus:t[5]||=e=>_.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>g(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(V(),H(`div`,AQ,[t[13]||=W(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(V(!0),H(B,null,R(c.value,e=>(V(),H(B,{key:e},[W(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>v(e,`summary`)},M(e),9,jQ),W(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>v(e,`result`)},M(e)+`.result`,9,MQ)],64))),128))])):q(``,!0)])):q(``,!0),p.value.compact.length?(V(),H(`section`,NQ,[(V(!0),H(B,null,R(p.value.compact,e=>(V(),H(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[W(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[K(M(S(e.key,e.schema))+` `,1),e.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,PQ),e.kind===`boolean`?(V(),U(P(zO),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>g(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(V(),H(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:C(e.key),onChange:t=>g(e.key,t.target.value||void 0)},[t[14]||=W(`option`,{value:``},`Default`,-1),(V(!0),H(B,null,R(e.schema.enum,e=>(V(),H(`option`,{key:e,value:e},M(e),9,IQ))),128))],40,FQ)):e.kind===`number`?(V(),H(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>g(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,LQ)):(V(),H(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:C(e.key),onFocus:t=>_.value=e.key,onInput:t=>g(e.key,t.target.value)},null,40,RQ))]))),128))])):q(``,!0),(V(!0),H(B,null,R(p.value.long,e=>(V(),H(`section`,{key:e.key,class:`space-y-1.5`},[W(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[K(M(S(e.key,e.schema))+` `,1),e.schema.description?(V(),U(P(ld),{key:0,class:`size-3 text-fg-subtle`})):q(``,!0)],8,zQ),e.kind===`text`?(V(),U(P(sT),{key:0,"model-value":C(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>_.value=e.key,"onUpdate:modelValue":t=>g(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(V(),U(P(sT),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`):``,class:`min-h-16 font-mono text-xs`,placeholder:`One per line`,"onUpdate:modelValue":t=>g(e.key,String(t).split(`
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(V(),H(B,{key:2},[G(P(cT),{"model-value":x(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>b(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),y.value[e.key]?(V(),H(`span`,BQ,M(y.value[e.key]),1)):q(``,!0)],64))]))),128)),W(`section`,VQ,[t[19]||=W(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),W(`div`,HQ,[W(`label`,UQ,[t[15]||=W(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),W(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,WQ)]),W(`label`,GQ,[t[17]||=W(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),W(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[16]||=[W(`option`,{value:``},`Park the task`,-1),W(`option`,{value:`continue`},`Continue`,-1)]],40,KQ)]),W(`label`,qQ,[t[18]||=W(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),W(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>h(`retry`,e.target.value===``?void 0:{...i.value.retry,attempts:Number(e.target.value)})},null,40,JQ)])])])]),W(`footer`,YQ,[G(P($),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[10]||=e=>r(`remove`)},{default:F(()=>[G(P(Hd)),t[20]||=K(` Delete step`,-1)]),_:1}),G(P($),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[11]||=e=>r(`close`)},{default:F(()=>[...t[21]||=[K(`Done`,-1)]]),_:1})])]))}}),ZQ=`repository_path`;function QQ(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:ZQ,path:n.trim(),type:`string`,required:!0}),r}function $Q(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function e$(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=$Q(yP(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function t$(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:yP(e.value,i.type??`string`)})}return n}function n$(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function r$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...r$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...r$(n,r)]}):[]}function i$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function a$(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function o$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var s$={class:`flex h-full flex-col`},c$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},l$={class:`min-w-0 flex-1 truncate text-sm font-medium`},u$={key:0,class:`flex flex-1 items-center justify-center`},d$={class:`space-y-1.5`},f$=[`disabled`],p$=[`value`],m$={key:1,class:`space-y-1.5`},h$=[`value`],g$=[`title`],_$={class:`space-y-1.5`},v$={id:`bind-paths`},y$=[`value`],b$={class:`divide-y divide-border rounded-md border border-border`},x$={class:`flex items-center gap-1.5 text-xs`},S$={class:`font-mono`},C$={class:`text-fg-subtle`},w$={key:0,class:`text-danger`,title:`Required`},T$=[`title`,`aria-label`,`onClick`],E$=[`onUpdate:modelValue`,`aria-label`],D$=[`onUpdate:modelValue`,`aria-label`],O$={key:2,class:`text-xs text-danger`},k$=[`title`],A$={key:0,class:`space-y-1 px-3 py-2`},j$={key:0,class:`text-xs text-danger`},M$={key:1,class:`truncate font-mono text-xs text-success`},N$={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},P$={class:`space-y-2`},F$={key:0,role:`alert`,class:`text-xs text-danger`},I$={key:1,class:`text-xs text-fg-subtle`},L$={class:`flex gap-2`},R$=`__new__`,z$=L({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>String(QZ(n.yaml,`id`)??``)),a=Y(()= Line truncated
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(V(),H(B,{key:2},[G(P(sT),{"model-value":x(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>b(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),y.value[e.key]?(V(),H(`span`,BQ,M(y.value[e.key]),1)):q(``,!0)],64))]))),128)),W(`section`,VQ,[t[19]||=W(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),W(`div`,HQ,[W(`label`,UQ,[t[15]||=W(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),W(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,WQ)]),W(`label`,GQ,[t[17]||=W(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),W(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[16]||=[W(`option`,{value:``},`Park the task`,-1),W(`option`,{value:`continue`},`Continue`,-1)]],40,KQ)]),W(`label`,qQ,[t[18]||=W(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),W(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>h(`retry`,e.target.value===``?void 0:{...i.value.retry,attempts:Number(e.target.value)})},null,40,JQ)])])])]),W(`footer`,YQ,[G(P($),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[10]||=e=>r(`remove`)},{default:F(()=>[G(P(Hd)),t[20]||=K(` Delete step`,-1)]),_:1}),G(P($),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[11]||=e=>r(`close`)},{default:F(()=>[...t[21]||=[K(`Done`,-1)]]),_:1})])]))}}),ZQ=`repository_path`;function QQ(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:ZQ,path:n.trim(),type:`string`,required:!0}),r}function $Q(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function e$(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=$Q(yP(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function t$(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:yP(e.value,i.type??`string`)})}return n}function n$(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function r$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...r$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...r$(n,r)]}):[]}function i$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function a$(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function o$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var s$={class:`flex h-full flex-col`},c$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},l$={class:`min-w-0 flex-1 truncate text-sm font-medium`},u$={key:0,class:`flex flex-1 items-center justify-center`},d$={class:`space-y-1.5`},f$=[`disabled`],p$=[`value`],m$={key:1,class:`space-y-1.5`},h$=[`value`],g$=[`title`],_$={class:`space-y-1.5`},v$={id:`bind-paths`},y$=[`value`],b$={class:`divide-y divide-border rounded-md border border-border`},x$={class:`flex items-center gap-1.5 text-xs`},S$={class:`font-mono`},C$={class:`text-fg-subtle`},w$={key:0,class:`text-danger`,title:`Required`},T$=[`title`,`aria-label`,`onClick`],E$=[`onUpdate:modelValue`,`aria-label`],D$=[`onUpdate:modelValue`,`aria-label`],O$={key:2,class:`text-xs text-danger`},k$=[`title`],A$={key:0,class:`space-y-1 px-3 py-2`},j$={key:0,class:`text-xs text-danger`},M$={key:1,class:`truncate font-mono text-xs text-success`},N$={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},P$={class:`space-y-2`},F$={key:0,role:`alert`,class:`text-xs text-danger`},I$={key:1,class:`text-xs text-fg-subtle`},L$={class:`flex gap-2`},R$=`__new__`,z$=L({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>String(QZ(n.yaml,`id`)??``)),a=Y(()= Line truncated
`).replace(`
`,`
+`).split(`
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function w5(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=T5(n.code,e);return Array.isArray(e)?e.some(e=>C5(n[r],e,t,n.type===`keyup`)):C5(n[r],e,t,n.type===`keyup`)}}function T5(e,t){return t.includes(e)?`code`:`key`}function E5(e,t){let n=Y(()=>pn(t?.target)??b5),r=ln(pn(e)===!0),i=!1,a=new Set,o=c(pn(e));I(()=>pn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),v0([`blur`,`contextmenu`],s),b0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0,a=pn(t?.preventDefault)??!1;if(i=S5(e),(!i||i&&!n)&&x5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),b0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&x5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=pn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?w5(e,a):e}return r}var D5=`vue-flow__node-desc`,O5=`vue-flow__edge-desc`,k5=`vue-flow__aria-live`,A5=[`Enter`,` `,`Escape`],j5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function M5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function N5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function P5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function F5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function I5(e,t){return{x:F5(e.x,t[0][0],t[1][0]),y:F5(e.y,t[0][1],t[1][1])}}function L5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function R5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function z5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!R5(e)}function B5(e){return z5(e)&&`computedPosition`in e}function V5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function H5(e){return V5(e.width)&&V5(e.height)&&V5(e.x)&&V5(e.y)}function U5(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:an({width:0,height:0}),computedPosition:an({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:G7(e.data)?e.data:{},events:an(G7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function W5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:G7(e.data)?e.data:{},events:an(G7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function G5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function K5(...e){if(e.length===3){let[t,n,r]=e;return G5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>R5(e)&&e.source===r).map(e=>n.find(t=>z5(t)&&t.id===e.target))}function q5(...e){if(e.length===3){let[t,n,r]=e;return G5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>R5(e)&&e.target===r).map(e=>n.find(t=>z5(t)&&t.id===e.source))}function J5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Y5(e,t){return t.some(t=>R5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function X5({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function Z5({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?F7(s,o):s}function Q5(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function $5({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function e7({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function t7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=Q5(t,$5({...r.computedPosition,...r.dimensions}))}return e7(t)}function n7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...Z5(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectable:n=!0,hidden:s= Line truncated
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function w5(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=T5(n.code,e);return Array.isArray(e)?e.some(e=>C5(n[r],e,t,n.type===`keyup`)):C5(n[r],e,t,n.type===`keyup`)}}function T5(e,t){return t.includes(e)?`code`:`key`}function E5(e,t){let n=Y(()=>pn(t?.target)??b5),r=ln(pn(e)===!0),i=!1,a=new Set,o=c(pn(e));I(()=>pn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),v0([`blur`,`contextmenu`],s),b0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0,a=pn(t?.preventDefault)??!1;if(i=S5(e),(!i||i&&!n)&&x5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),b0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&x5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=pn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?w5(e,a):e}return r}var D5=`vue-flow__node-desc`,O5=`vue-flow__edge-desc`,k5=`vue-flow__aria-live`,A5=[`Enter`,` `,`Escape`],j5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function M5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function N5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function P5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function F5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function I5(e,t){return{x:F5(e.x,t[0][0],t[1][0]),y:F5(e.y,t[0][1],t[1][1])}}function L5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function R5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function z5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!R5(e)}function B5(e){return z5(e)&&`computedPosition`in e}function V5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function H5(e){return V5(e.width)&&V5(e.height)&&V5(e.x)&&V5(e.y)}function U5(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:an({width:0,height:0}),computedPosition:an({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:G7(e.data)?e.data:{},events:an(G7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function W5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:G7(e.data)?e.data:{},events:an(G7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function G5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function K5(...e){if(e.length===3){let[t,n,r]=e;return G5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>R5(e)&&e.source===r).map(e=>n.find(t=>z5(t)&&t.id===e.target))}function q5(...e){if(e.length===3){let[t,n,r]=e;return G5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>R5(e)&&e.target===r).map(e=>n.find(t=>z5(t)&&t.id===e.source))}function J5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Y5(e,t){return t.some(t=>R5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function X5({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function Z5({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?F7(s,o):s}function Q5(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function $5({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function e7({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function t7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=Q5(t,$5({...r.computedPosition,...r.dimensions}))}return e7(t)}function n7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...Z5(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectable:n=!0,hidden:s= Line truncated
Node: ${e}`,NODE_NOT_FOUND:e=>`Node not found
Node: ${e}`,NODE_MISSING_PARENT:(e,t)=>`Node is missing a parent
Node: ${e}
@@ -153,4 +153,4 @@ Edge: ${e}
Source: ${t}
Target: ${n}`,EDGE_ORPHANED:e=>`Edge was orphaned (suddenly missing source or target) and has been removed
Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},j7=class extends Error{constructor(e,...t){super(A7[e]?.call(A7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function M7(e){return`clientX`in e}function Yte(e){return`sourceEvent`in e}function N7(e,t){let n=M7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var P7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function Xte(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function F7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var Zte=()=>!0;function I7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function Qte(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())N5(i,M5(e))>0&&r.push(e);return r}var $te=250;function ene(e,t,n,r){let i=[],a=1/0,o=Qte(e,n,t+$te);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=D7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function L7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Zte},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=N7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=R7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===h5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=z7(t,e,a,p,n,!0)}return b}function R7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function tne(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function nne(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function z7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===h5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...D7(o,c,c.position,!0)}:c}var B7={[f5.Left]:f5.Right,[f5.Right]:f5.Left,[f5.Top]:f5.Bottom,[f5.Bottom]:f5.Top},rne=[`production`,`prod`];function V7(e,...t){H7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function H7(){return!rne.includes(`production`)}function U7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...P5(t)}}):null}function W7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),qn(()=>{o.blur()})):n([e])}function G7(e){return P(e)!==void 0}function ine(e,t,n,r){if(!e||!e.source||!e.target)return n(new j7(k7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=R5(e)?e:{...e,id:J5(e)},i=W5(i,void 0,r),!Y5(i,t)&&i}function ane(e,t,n,r,i){if(!t.source||!t.target)return i(new j7(k7.EDGE_INVALID,e.id)),!1;if(!n)return i(new j7(k7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?J5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function K7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!z5(o)){n(new j7(k7.NODE_INVALID,o?.id));continue}let s=U5(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new j7(k7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function q7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function J7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;q7(`source`Line truncated
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},j7=class extends Error{constructor(e,...t){super(A7[e]?.call(A7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function M7(e){return`clientX`in e}function Xte(e){return`sourceEvent`in e}function N7(e,t){let n=M7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var P7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function Zte(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function F7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var Qte=()=>!0;function I7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function $te(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())N5(i,M5(e))>0&&r.push(e);return r}var ene=250;function tne(e,t,n,r){let i=[],a=1/0,o=$te(e,n,t+ene);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=D7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function L7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Qte},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=N7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=R7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===h5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=z7(t,e,a,p,n,!0)}return b}function R7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function nne(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function rne(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function z7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===h5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...D7(o,c,c.position,!0)}:c}var B7={[f5.Left]:f5.Right,[f5.Right]:f5.Left,[f5.Top]:f5.Bottom,[f5.Bottom]:f5.Top},ine=[`production`,`prod`];function V7(e,...t){H7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function H7(){return!ine.includes(`production`)}function U7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...P5(t)}}):null}function W7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),qn(()=>{o.blur()})):n([e])}function G7(e){return P(e)!==void 0}function ane(e,t,n,r){if(!e||!e.source||!e.target)return n(new j7(k7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=R5(e)?e:{...e,id:J5(e)},i=W5(i,void 0,r),!Y5(i,t)&&i}function one(e,t,n,r,i){if(!t.source||!t.target)return i(new j7(k7.EDGE_INVALID,e.id)),!1;if(!n)return i(new j7(k7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?J5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function K7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!z5(o)){n(new j7(k7.NODE_INVALID,o?.id));continue}let s=U5(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new j7(k7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function q7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function J7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;q7(`source`Line truncated
+4
View File
@@ -336,6 +336,10 @@ export const api = {
request<T>(`/api/sources/${encodeURIComponent(path)}/approve-unsigned`, {
method: "POST",
}),
sourceName: <T = unknown>(path: string, name: string) =>
request<T>(`/api/sources/${encodeURIComponent(path)}/name`, { method: "PUT", body: { name } }),
sourceDelete: (path: string) =>
request<void>(`/api/sources/${encodeURIComponent(path)}`, { method: "DELETE", parse: false }),
sourceSecret: <T = unknown>(path: string) =>
request<T>(`/api/sources/${encodeURIComponent(path)}/secret`, {
method: "POST",
+25 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { Check, Copy, KeyRound, Lock, LockOpen, Plus } from "@lucide/vue";
import { Check, Copy, KeyRound, Lock, LockOpen, Plus, Trash2 } from "@lucide/vue";
import { onMounted, ref } from "vue";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
@@ -46,6 +46,8 @@ const {
requestUnsigned,
requireSigning,
approveUnsigned,
rename,
remove,
refusals,
} = useSources();
@@ -111,7 +113,14 @@ function url(source: Source): string {
<TableCell
class="max-w-0 truncate font-mono text-fg-muted"
:title="url(source)"
>{{ source.path }}
><input
class="block w-full bg-transparent font-sans text-sm text-foreground outline-none placeholder:text-fg-subtle focus:underline"
:value="source.name ?? ''"
placeholder="Name this source"
:aria-label="`Name of source ${source.path}`"
:disabled="busy"
@change="rename(source, ($event.target as HTMLInputElement).value)"
/>{{ source.path }}
<div
v-if="refusals[source.path]"
class="text-xs font-sans text-destructive"
@@ -185,6 +194,20 @@ function url(source: Source): string {
<Lock data-icon="inline-start" />
Require signing
</Button>
<Tooltip>
<TooltipTrigger as-child>
<Button
variant="ghost"
size="icon-sm"
aria-label="Delete source"
:disabled="busy"
@click="remove(source)"
>
<Trash2 />
</Button>
</TooltipTrigger>
<TooltipContent>Delete source</TooltipContent>
</Tooltip>
</div>
</TableCell>
</TableRow>
+2
View File
@@ -6,6 +6,8 @@
export interface Source {
path: string;
/** The operator's label; the path stays the source's identity. */
name?: string;
signing?: string;
/** Present only on create and on a new secret. */
secret?: string;
+5
View File
@@ -64,5 +64,10 @@ export function useSources() {
run(() => api.sourceSigning<Source>(source.path, true)),
approveUnsigned: (source: Source) =>
run(() => api.sourceApproveUnsigned<Source>(source.path)),
rename: (source: Source, name: string) =>
run(() => api.sourceName<Source>(source.path, name.trim())),
// An armed binding on the source refuses the delete; the refusal shows
// as the panel's failure.
remove: (source: Source) => run(() => api.sourceDelete(source.path)),
};
}
+5 -2
View File
@@ -39,6 +39,8 @@ const inputs = computed(() =>
const repository = computed(() => takesRepository({ id: "", name: "", repository: String(workflowField(props.yaml, "repository") ?? "") || undefined }));
const sources = ref<string[]>([]);
// The operator's label for each source path, where one is set.
const sourceNames = ref<Record<string, string>>({});
const captures = ref<Capture[]>([]);
const eventTypes = ref<EventType[]>([]);
const mappings = ref<Mapping[]>([]);
@@ -64,13 +66,14 @@ async function loadCaptures(): Promise<void> {
onMounted(async () => {
const [listed, types, mapped, bound] = await Promise.all([
api.sources<{ sources?: { path: string }[] }>().catch(() => null),
api.sources<{ sources?: { path: string; name?: string }[] }>().catch(() => null),
api.eventTypes<{ event_types?: EventType[] }>().catch(() => null),
api.mappings<{ mappings?: Mapping[] }>().catch(() => null),
api.bindings<{ bindings?: Binding[] }>().catch(() => null),
loadCaptures(),
]);
sources.value = (listed?.sources ?? []).map((s) => s.path);
sourceNames.value = Object.fromEntries((listed?.sources ?? []).filter((s) => s.name).map((s) => [s.path, s.name!]));
eventTypes.value = types?.event_types ?? [];
mappings.value = mapped?.mappings ?? [];
bindings.value = bound?.bindings ?? [];
@@ -235,7 +238,7 @@ const resume = () => transition(api.bindingResume, "pending_approval");
<label for="bind-source" class="text-xs font-medium text-muted-foreground">Source</label>
<select id="bind-source" v-model="source" class="h-8 w-full rounded-md border border-input bg-background px-2 text-[13px]" :disabled="!!binding">
<option value="" disabled>Pick a source</option>
<option v-for="path in sources" :key="path" :value="path">{{ path }}</option>
<option v-for="path in sources" :key="path" :value="path">{{ sourceNames[path] ? `${sourceNames[path]} (${path})` : path }}</option>
<option :value="NEW_SOURCE">New source…</option>
</select>
<input