diff --git a/apiclient/types/knowledge.go b/apiclient/types/knowledge.go index 77baaa15..32c7b188 100644 --- a/apiclient/types/knowledge.go +++ b/apiclient/types/knowledge.go @@ -2,13 +2,14 @@ package types type KnowledgeFile struct { Metadata - FileName string `json:"fileName"` - AgentID string `json:"agentID,omitempty"` - WorkflowID string `json:"workflowID,omitempty"` - ThreadID string `json:"threadID,omitempty"` - UploadID string `json:"uploadID,omitempty"` - IngestionStatus IngestionStatus `json:"ingestionStatus,omitempty"` - FileDetails FileDetails `json:"fileDetails,omitempty"` + FileName string `json:"fileName"` + AgentID string `json:"agentID,omitempty"` + WorkflowID string `json:"workflowID,omitempty"` + ThreadID string `json:"threadID,omitempty"` + RemoteKnowledgeSourceID string `json:"remoteKnowledgeSourceID,omitempty"` + RemoteKnowledgeSourceType RemoteKnowledgeSourceType `json:"remoteKnowledgeSourceType,omitempty"` + IngestionStatus IngestionStatus `json:"ingestionStatus,omitempty"` + FileDetails FileDetails `json:"fileDetails,omitempty"` } type FileDetails struct { diff --git a/apiclient/types/onedrive.go b/apiclient/types/onedrive.go deleted file mode 100644 index aadf4fff..00000000 --- a/apiclient/types/onedrive.go +++ /dev/null @@ -1,15 +0,0 @@ -package types - -type OneDriveLinks struct { - Metadata - AgentID string `json:"agentID,omitempty"` - WorkflowID string `json:"workflowID,omitempty"` - SharedLinks []string `json:"sharedLinks,omitempty"` - ThreadID string `json:"threadID,omitempty"` - RunID string `json:"runID,omitempty"` - Status string `json:"status,omitempty"` - Error string `json:"error,omitempty"` - Folders FolderSet `json:"folders,omitempty"` -} - -type OneDriveLinksList List[OneDriveLinks] diff --git a/apiclient/types/remoteKnowledgeSource.go b/apiclient/types/remoteKnowledgeSource.go new file mode 100644 index 00000000..42573f0d --- /dev/null +++ b/apiclient/types/remoteKnowledgeSource.go @@ -0,0 +1,67 @@ +package types + +var ( + RemoteKnowledgeSourceTypeOneDrive RemoteKnowledgeSourceType = "onedrive" + RemoteKnowledgeSourceTypeNotion RemoteKnowledgeSourceType = "notion" + RemoteKnowledgeSourceTypeWebsite RemoteKnowledgeSourceType = "website" +) + +type RemoteKnowledgeSourceType string + +type RemoteKnowledgeSource struct { + Metadata + AgentID string `json:"agentID,omitempty"` + WorkflowID string `json:"workflowID,omitempty"` + ThreadID string `json:"threadID,omitempty"` + RunID string `json:"runID,omitempty"` + Input RemoteKnowledgeSourceInput `json:"input,omitempty"` + State RemoteKnowledgeSourceState `json:"state,omitempty"` + Status string `json:"status,omitempty"` + Error string `json:"error,omitempty"` +} + +type RemoteKnowledgeSourceList List[RemoteKnowledgeSource] + +type RemoteKnowledgeSourceInput struct { + SourceType RemoteKnowledgeSourceType `json:"sourceType,omitempty"` + Exclude []string `json:"exclude,omitempty"` + OneDriveConfig *OneDriveConfig `json:"onedriveConfig,omitempty"` + NotionConfig *NotionConfig `json:"notionConfig,omitempty"` + WebsiteCrawlingConfig *WebsiteCrawlingConfig `json:"websiteCrawlingConfig,omitempty"` +} + +type OneDriveConfig struct { + SharedLinks []string `json:"sharedLinks,omitempty"` +} + +type NotionConfig struct { + Pages []string `json:"pages,omitempty"` +} + +type WebsiteCrawlingConfig struct { + URLs []string `json:"urls,omitempty"` +} + +type RemoteKnowledgeSourceState struct { + OneDriveState *OneDriveLinksConnectorState `json:"onedriveState,omitempty"` + NotionState *NotionConnectorState `json:"notionState,omitempty"` + WebsiteCrawlingState *WebsiteCrawlingConnectorState `json:"websiteCrawlingState,omitempty"` +} + +type OneDriveLinksConnectorState struct { + Folders FolderSet `json:"folders,omitempty"` +} + +type NotionConnectorState struct { + Pages map[string]NotionPage `json:"pages,omitempty"` +} + +type NotionPage struct { + URL string `json:"url,omitempty"` + Title string `json:"title,omitempty"` +} + +type WebsiteCrawlingConnectorState struct { + ScrapeJobIds map[string]string `json:"scrapeJobIds"` + Folders FolderSet `json:"folders"` +} diff --git a/apiclient/types/zz_generated.deepcopy.go b/apiclient/types/zz_generated.deepcopy.go index 64cb3a0f..ffa48a5f 100644 --- a/apiclient/types/zz_generated.deepcopy.go +++ b/apiclient/types/zz_generated.deepcopy.go @@ -368,51 +368,100 @@ func (in *Metadata) DeepCopy() *Metadata { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OneDriveLinks) DeepCopyInto(out *OneDriveLinks) { +func (in *NotionConfig) DeepCopyInto(out *NotionConfig) { *out = *in - in.Metadata.DeepCopyInto(&out.Metadata) - if in.SharedLinks != nil { - in, out := &in.SharedLinks, &out.SharedLinks + if in.Pages != nil { + in, out := &in.Pages, &out.Pages *out = make([]string, len(*in)) copy(*out, *in) } - if in.Folders != nil { - in, out := &in.Folders, &out.Folders - *out = make(FolderSet, len(*in)) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotionConfig. +func (in *NotionConfig) DeepCopy() *NotionConfig { + if in == nil { + return nil + } + out := new(NotionConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NotionConnectorState) DeepCopyInto(out *NotionConnectorState) { + *out = *in + if in.Pages != nil { + in, out := &in.Pages, &out.Pages + *out = make(map[string]NotionPage, len(*in)) for key, val := range *in { (*out)[key] = val } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinks. -func (in *OneDriveLinks) DeepCopy() *OneDriveLinks { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotionConnectorState. +func (in *NotionConnectorState) DeepCopy() *NotionConnectorState { if in == nil { return nil } - out := new(OneDriveLinks) + out := new(NotionConnectorState) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OneDriveLinksList) DeepCopyInto(out *OneDriveLinksList) { +func (in *NotionPage) DeepCopyInto(out *NotionPage) { *out = *in - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OneDriveLinks, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NotionPage. +func (in *NotionPage) DeepCopy() *NotionPage { + if in == nil { + return nil + } + out := new(NotionPage) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OneDriveConfig) DeepCopyInto(out *OneDriveConfig) { + *out = *in + if in.SharedLinks != nil { + in, out := &in.SharedLinks, &out.SharedLinks + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveConfig. +func (in *OneDriveConfig) DeepCopy() *OneDriveConfig { + if in == nil { + return nil + } + out := new(OneDriveConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OneDriveLinksConnectorState) DeepCopyInto(out *OneDriveLinksConnectorState) { + *out = *in + if in.Folders != nil { + in, out := &in.Folders, &out.Folders + *out = make(FolderSet, len(*in)) + for key, val := range *in { + (*out)[key] = val } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinksList. -func (in *OneDriveLinksList) DeepCopy() *OneDriveLinksList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinksConnectorState. +func (in *OneDriveLinksConnectorState) DeepCopy() *OneDriveLinksConnectorState { if in == nil { return nil } - out := new(OneDriveLinksList) + out := new(OneDriveLinksConnectorState) in.DeepCopyInto(out) return out } @@ -483,6 +532,111 @@ func (in *Prompt) DeepCopy() *Prompt { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteKnowledgeSource) DeepCopyInto(out *RemoteKnowledgeSource) { + *out = *in + in.Metadata.DeepCopyInto(&out.Metadata) + in.Input.DeepCopyInto(&out.Input) + in.State.DeepCopyInto(&out.State) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSource. +func (in *RemoteKnowledgeSource) DeepCopy() *RemoteKnowledgeSource { + if in == nil { + return nil + } + out := new(RemoteKnowledgeSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteKnowledgeSourceInput) DeepCopyInto(out *RemoteKnowledgeSourceInput) { + *out = *in + if in.Exclude != nil { + in, out := &in.Exclude, &out.Exclude + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.OneDriveConfig != nil { + in, out := &in.OneDriveConfig, &out.OneDriveConfig + *out = new(OneDriveConfig) + (*in).DeepCopyInto(*out) + } + if in.NotionConfig != nil { + in, out := &in.NotionConfig, &out.NotionConfig + *out = new(NotionConfig) + (*in).DeepCopyInto(*out) + } + if in.WebsiteCrawlingConfig != nil { + in, out := &in.WebsiteCrawlingConfig, &out.WebsiteCrawlingConfig + *out = new(WebsiteCrawlingConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceInput. +func (in *RemoteKnowledgeSourceInput) DeepCopy() *RemoteKnowledgeSourceInput { + if in == nil { + return nil + } + out := new(RemoteKnowledgeSourceInput) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteKnowledgeSourceList) DeepCopyInto(out *RemoteKnowledgeSourceList) { + *out = *in + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]RemoteKnowledgeSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceList. +func (in *RemoteKnowledgeSourceList) DeepCopy() *RemoteKnowledgeSourceList { + if in == nil { + return nil + } + out := new(RemoteKnowledgeSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteKnowledgeSourceState) DeepCopyInto(out *RemoteKnowledgeSourceState) { + *out = *in + if in.OneDriveState != nil { + in, out := &in.OneDriveState, &out.OneDriveState + *out = new(OneDriveLinksConnectorState) + (*in).DeepCopyInto(*out) + } + if in.NotionState != nil { + in, out := &in.NotionState, &out.NotionState + *out = new(NotionConnectorState) + (*in).DeepCopyInto(*out) + } + if in.WebsiteCrawlingState != nil { + in, out := &in.WebsiteCrawlingState, &out.WebsiteCrawlingState + *out = new(WebsiteCrawlingConnectorState) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceState. +func (in *RemoteKnowledgeSourceState) DeepCopy() *RemoteKnowledgeSourceState { + if in == nil { + return nil + } + out := new(RemoteKnowledgeSourceState) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Run) DeepCopyInto(out *Run) { *out = *in @@ -848,6 +1002,55 @@ func (in *WebhookManifest) DeepCopy() *WebhookManifest { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebsiteCrawlingConfig) DeepCopyInto(out *WebsiteCrawlingConfig) { + *out = *in + if in.URLs != nil { + in, out := &in.URLs, &out.URLs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebsiteCrawlingConfig. +func (in *WebsiteCrawlingConfig) DeepCopy() *WebsiteCrawlingConfig { + if in == nil { + return nil + } + out := new(WebsiteCrawlingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebsiteCrawlingConnectorState) DeepCopyInto(out *WebsiteCrawlingConnectorState) { + *out = *in + if in.ScrapeJobIds != nil { + in, out := &in.ScrapeJobIds, &out.ScrapeJobIds + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Folders != nil { + in, out := &in.Folders, &out.Folders + *out = make(FolderSet, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebsiteCrawlingConnectorState. +func (in *WebsiteCrawlingConnectorState) DeepCopy() *WebsiteCrawlingConnectorState { + if in == nil { + return nil + } + out := new(WebsiteCrawlingConnectorState) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *While) DeepCopyInto(out *While) { *out = *in diff --git a/pkg/api/handlers/agent.go b/pkg/api/handlers/agent.go index 884005ce..b1b1c83f 100644 --- a/pkg/api/handlers/agent.go +++ b/pkg/api/handlers/agent.go @@ -199,24 +199,24 @@ func (a *AgentHandler) IngestKnowledge(req api.Context) error { return ingestKnowledge(req, a.workspaceClient, agent.Status.KnowledgeWorkspaceName) } -func (a *AgentHandler) CreateOnedriveLinks(req api.Context) error { - return createOneDriveLinks(req, req.PathValue("agent_id"), new(v1.Agent)) +func (a *AgentHandler) CreateRemoteKnowledgeSource(req api.Context) error { + return createRemoteKnowledgeSource(req, req.PathValue("agent_id"), new(v1.Agent)) } -func (a *AgentHandler) UpdateOnedriveLinks(req api.Context) error { - return updateOneDriveLinks(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) +func (a *AgentHandler) UpdateRemoteKnowledgeSource(req api.Context) error { + return updateRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) } -func (a *AgentHandler) ReSyncOnedriveLinks(req api.Context) error { - return reSyncOneDriveLinks(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) +func (a *AgentHandler) ReSyncRemoteKnowledgeSource(req api.Context) error { + return reSyncRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) } -func (a *AgentHandler) GetOnedriveLinks(req api.Context) error { - return getOneDriveLinksForParent(req, req.PathValue("agent_id"), new(v1.Agent)) +func (a *AgentHandler) GetRemoteKnowledgeSources(req api.Context) error { + return getRemoteKnowledgeSourceForParent(req, req.PathValue("agent_id"), new(v1.Agent)) } -func (a *AgentHandler) DeleteOnedriveLinks(req api.Context) error { - return deleteOneDriveLinks(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) +func (a *AgentHandler) DeleteRemoteKnowledgeSource(req api.Context) error { + return deleteRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("agent_id"), new(v1.Agent)) } func (a *AgentHandler) Script(req api.Context) error { diff --git a/pkg/api/handlers/files.go b/pkg/api/handlers/files.go index 9d13be2b..499520ec 100644 --- a/pkg/api/handlers/files.go +++ b/pkg/api/handlers/files.go @@ -116,14 +116,15 @@ func uploadKnowledgeToWorkspace(req api.Context, wc *wclient.Client, ws v1.Works func convertKnowledgeFile(file v1.KnowledgeFile, ws v1.Workspace) types.KnowledgeFile { return types.KnowledgeFile{ - Metadata: MetadataFrom(&file), - FileName: file.Spec.FileName, - AgentID: ws.Spec.AgentName, - WorkflowID: ws.Spec.WorkflowName, - ThreadID: ws.Spec.ThreadName, - IngestionStatus: file.Status.IngestionStatus, - FileDetails: file.Status.FileDetails, - UploadID: file.Spec.UploadName, + Metadata: MetadataFrom(&file), + FileName: file.Spec.FileName, + AgentID: ws.Spec.AgentName, + WorkflowID: ws.Spec.WorkflowName, + ThreadID: ws.Spec.ThreadName, + IngestionStatus: file.Status.IngestionStatus, + FileDetails: file.Status.FileDetails, + RemoteKnowledgeSourceID: file.Spec.RemoteKnowledgeSourceName, + RemoteKnowledgeSourceType: file.Spec.RemoteKnowledgeSourceType, } } diff --git a/pkg/api/handlers/onedrive.go b/pkg/api/handlers/onedrive.go deleted file mode 100644 index a4a490d5..00000000 --- a/pkg/api/handlers/onedrive.go +++ /dev/null @@ -1,185 +0,0 @@ -package handlers - -import ( - "errors" - "fmt" - "net/http" - - "github.com/gptscript-ai/otto/apiclient/types" - "github.com/gptscript-ai/otto/pkg/api" - v1 "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1" - "github.com/gptscript-ai/otto/pkg/system" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -func createOneDriveLinks(req api.Context, parentName string, parentObj client.Object) error { - if err := req.Get(parentObj, parentName); err != nil { - return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) - } - - var links []string - if err := req.Read(&links); err != nil { - return fmt.Errorf("failed to decode request body: %w", err) - } - - oneDriveLinks := &v1.OneDriveLinks{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "ol1", - Namespace: req.Namespace(), - }, - Spec: v1.OnedriveLinksSpec{ - SharedLinks: links, - }, - } - - switch parentObj.(type) { - case *v1.Agent: - oneDriveLinks.Spec.AgentName = parentName - case *v1.Workflow: - oneDriveLinks.Spec.WorkflowName = parentName - default: - return fmt.Errorf("unknown parent object type: %T", parentObj) - } - - if err := req.Create(oneDriveLinks); err != nil { - return fmt.Errorf("failed to create OneDrive links: %w", err) - } - - if err := createSyncRequest(req, *oneDriveLinks); err != nil { - return fmt.Errorf("failed to create sync request: %w", err) - } - - return req.Write(convertOneDriveLinks(*oneDriveLinks)) -} - -func updateOneDriveLinks(req api.Context, linksID, parentName string, parentObj client.Object) error { - if err := req.Get(parentObj, parentName); err != nil { - return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) - } - - var oneDriveLinks v1.OneDriveLinks - if err := req.Get(&oneDriveLinks, linksID); err != nil { - return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) - } - - if oneDriveLinks.Spec.AgentName != parentName && oneDriveLinks.Spec.WorkflowName != parentName { - return fmt.Errorf("OneDrive links agent name %q does not match provided agent name %q", oneDriveLinks.Spec.AgentName, parentName) - } - - var links []string - if err := req.Read(&links); err != nil { - return fmt.Errorf("failed to decode request body: %w", err) - } - - oneDriveLinks.Spec.SharedLinks = links - - if err := req.Update(&oneDriveLinks); err != nil { - return fmt.Errorf("failed to update OneDrive links: %w", err) - } - - if err := createSyncRequest(req, oneDriveLinks); err != nil { - return fmt.Errorf("failed to create sync request: %w", err) - } - - req.WriteHeader(http.StatusNoContent) - return nil -} - -func reSyncOneDriveLinks(req api.Context, linksID, parentName string, parentObj client.Object) error { - if err := req.Get(parentObj, parentName); err != nil { - return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) - } - - var oneDriveLinks v1.OneDriveLinks - if err := req.Get(&oneDriveLinks, linksID); err != nil { - return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) - } - - if oneDriveLinks.Spec.AgentName != parentName && oneDriveLinks.Spec.WorkflowName != parentName { - return fmt.Errorf("OneDrive links agent name %q does not match provided agent name %q", oneDriveLinks.Spec.AgentName, parentName) - } - - if err := createSyncRequest(req, oneDriveLinks); err != nil { - return fmt.Errorf("failed to create sync request: %w", err) - } - - req.WriteHeader(http.StatusNoContent) - return nil -} - -func createSyncRequest(req api.Context, oneDriveLinks v1.OneDriveLinks) error { - if err := req.Storage.Create(req.Context(), &v1.SyncUploadRequest{ - ObjectMeta: metav1.ObjectMeta{ - GenerateName: system.SyncRequestPrefix, - Namespace: oneDriveLinks.Namespace, - }, - Spec: v1.SyncUploadRequestSpec{ - UploadName: oneDriveLinks.Name, - }, - }); err != nil { - return fmt.Errorf("failed to create sync request: %w", err) - } - - return nil -} - -func getOneDriveLinksForParent(req api.Context, parentName string, parentObj client.Object) error { - if err := req.Get(parentObj, parentName); err != nil { - return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) - } - - var oneDriveLinks v1.OneDriveLinksList - if err := req.List(&oneDriveLinks); err != nil { - return fmt.Errorf("failed to get OneDrive links with id %s: %w", parentName, err) - } - - resp := make([]types.OneDriveLinks, 0, len(oneDriveLinks.Items)) - for _, link := range oneDriveLinks.Items { - if link.Spec.WorkflowName == parentName || link.Spec.AgentName == parentName { - resp = append(resp, convertOneDriveLinks(link)) - } - } - - return req.Write(types.OneDriveLinksList{Items: resp}) -} - -func deleteOneDriveLinks(req api.Context, linksID, parentName string, parentObj client.Object) error { - if err := req.Get(parentObj, parentName); err != nil { - return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) - } - - var ( - httpErr *types.ErrHTTP - oneDriveLinks v1.OneDriveLinks - ) - if err := req.Get(&oneDriveLinks, linksID); errors.As(err, &httpErr) { - return nil - } else if err != nil { - return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) - } - - if oneDriveLinks.Spec.AgentName != parentName && oneDriveLinks.Spec.WorkflowName != parentName { - return fmt.Errorf("OneDrive links name %q does not match provided agent name %q", oneDriveLinks.Spec.AgentName, parentName) - } - - if err := req.Delete(&oneDriveLinks); err != nil { - return fmt.Errorf("failed to delete OneDrive links: %w", err) - } - - return nil -} - -func convertOneDriveLinks(oneDriveLink v1.OneDriveLinks) types.OneDriveLinks { - return types.OneDriveLinks{ - Metadata: MetadataFrom(&oneDriveLink), - AgentID: oneDriveLink.Spec.AgentName, - WorkflowID: oneDriveLink.Spec.WorkflowName, - SharedLinks: oneDriveLink.Spec.SharedLinks, - ThreadID: oneDriveLink.Status.ThreadName, - RunID: oneDriveLink.Status.RunName, - Status: oneDriveLink.Status.Status, - Error: oneDriveLink.Status.Error, - Folders: oneDriveLink.Status.Folders, - } -} diff --git a/pkg/api/handlers/remoteknowledgesource.go b/pkg/api/handlers/remoteknowledgesource.go new file mode 100644 index 00000000..17aa0563 --- /dev/null +++ b/pkg/api/handlers/remoteknowledgesource.go @@ -0,0 +1,185 @@ +package handlers + +import ( + "errors" + "fmt" + "net/http" + + "github.com/gptscript-ai/otto/apiclient/types" + "github.com/gptscript-ai/otto/pkg/api" + v1 "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1" + "github.com/gptscript-ai/otto/pkg/system" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func createRemoteKnowledgeSource(req api.Context, parentName string, parentObj client.Object) error { + if err := req.Get(parentObj, parentName); err != nil { + return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) + } + + var input types.RemoteKnowledgeSourceInput + if err := req.Read(&input); err != nil { + return fmt.Errorf("failed to decode request body: %w", err) + } + + remoteKnowledgeSource := &v1.RemoteKnowledgeSource{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "remote-knowledge-source-", + Namespace: req.Namespace(), + }, + Spec: v1.RemoteKnowledgeSourceSpec{ + Input: input, + }, + } + + switch parentObj.(type) { + case *v1.Agent: + remoteKnowledgeSource.Spec.AgentName = parentName + case *v1.Workflow: + remoteKnowledgeSource.Spec.WorkflowName = parentName + default: + return fmt.Errorf("unknown parent object type: %T", parentObj) + } + + if err := req.Create(remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to create OneDrive links: %w", err) + } + + if err := createSyncRequest(req, *remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to create sync request: %w", err) + } + + return req.Write(convertRemoteKnowledgeSource(*remoteKnowledgeSource)) +} + +func updateRemoteKnowledgeSource(req api.Context, linksID, parentName string, parentObj client.Object) error { + if err := req.Get(parentObj, parentName); err != nil { + return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) + } + + var remoteKnowledgeSource v1.RemoteKnowledgeSource + if err := req.Get(&remoteKnowledgeSource, linksID); err != nil { + return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) + } + + if remoteKnowledgeSource.Spec.AgentName != parentName && remoteKnowledgeSource.Spec.WorkflowName != parentName { + return fmt.Errorf("RemoteKnowledgeSource agent name %q does not match provided agent name %q", remoteKnowledgeSource.Spec.AgentName, parentName) + } + + var input types.RemoteKnowledgeSourceInput + if err := req.Read(&input); err != nil { + return fmt.Errorf("failed to decode request body: %w", err) + } + + remoteKnowledgeSource.Spec.Input = input + + if err := req.Update(&remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to update OneDrive links: %w", err) + } + + if err := createSyncRequest(req, remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to create sync request: %w", err) + } + + req.WriteHeader(http.StatusNoContent) + return nil +} + +func reSyncRemoteKnowledgeSource(req api.Context, linksID, parentName string, parentObj client.Object) error { + if err := req.Get(parentObj, parentName); err != nil { + return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) + } + + var remoteKnowledgeSource v1.RemoteKnowledgeSource + if err := req.Get(&remoteKnowledgeSource, linksID); err != nil { + return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) + } + + if remoteKnowledgeSource.Spec.AgentName != parentName && remoteKnowledgeSource.Spec.WorkflowName != parentName { + return fmt.Errorf("RemoteKnowledgeSource agent name %q does not match provided agent name %q", remoteKnowledgeSource.Spec.AgentName, parentName) + } + + if err := createSyncRequest(req, remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to create sync request: %w", err) + } + + req.WriteHeader(http.StatusNoContent) + return nil +} + +func createSyncRequest(req api.Context, remoteKnowledgeSource v1.RemoteKnowledgeSource) error { + if err := req.Storage.Create(req.Context(), &v1.SyncUploadRequest{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: system.SyncRequestPrefix, + Namespace: remoteKnowledgeSource.Namespace, + }, + Spec: v1.SyncUploadRequestSpec{ + RemoteKnowledgeSourceName: remoteKnowledgeSource.Name, + }, + }); err != nil { + return fmt.Errorf("failed to create sync request: %w", err) + } + + return nil +} + +func getRemoteKnowledgeSourceForParent(req api.Context, parentName string, parentObj client.Object) error { + if err := req.Get(parentObj, parentName); err != nil { + return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) + } + + var remoteKnowledgeSourceList v1.RemoteKnowledgeSourceList + if err := req.List(&remoteKnowledgeSourceList); err != nil { + return fmt.Errorf("failed to get OneDrive links with id %s: %w", parentName, err) + } + + resp := make([]types.RemoteKnowledgeSource, 0, len(remoteKnowledgeSourceList.Items)) + for _, source := range remoteKnowledgeSourceList.Items { + if source.Spec.WorkflowName == parentName || source.Spec.AgentName == parentName { + resp = append(resp, convertRemoteKnowledgeSource(source)) + } + } + + return req.Write(types.RemoteKnowledgeSourceList{Items: resp}) +} + +func deleteRemoteKnowledgeSource(req api.Context, linksID, parentName string, parentObj client.Object) error { + if err := req.Get(parentObj, parentName); err != nil { + return fmt.Errorf("failed to get parent with id %s: %w", parentName, err) + } + + var ( + httpErr *types.ErrHTTP + remoteKnowledgeSource v1.RemoteKnowledgeSource + ) + if err := req.Get(&remoteKnowledgeSource, linksID); errors.As(err, &httpErr) { + return nil + } else if err != nil { + return fmt.Errorf("failed to get OneDrive links with id %s: %w", linksID, err) + } + + if remoteKnowledgeSource.Spec.AgentName != parentName && remoteKnowledgeSource.Spec.WorkflowName != parentName { + return fmt.Errorf("OneDrive links name %q does not match provided agent name %q", remoteKnowledgeSource.Spec.AgentName, parentName) + } + + if err := req.Delete(&remoteKnowledgeSource); err != nil { + return fmt.Errorf("failed to delete OneDrive links: %w", err) + } + + return nil +} + +func convertRemoteKnowledgeSource(remoteKnowledgeSource v1.RemoteKnowledgeSource) types.RemoteKnowledgeSource { + return types.RemoteKnowledgeSource{ + Metadata: MetadataFrom(&remoteKnowledgeSource), + AgentID: remoteKnowledgeSource.Spec.AgentName, + WorkflowID: remoteKnowledgeSource.Spec.WorkflowName, + Input: remoteKnowledgeSource.Spec.Input, + State: remoteKnowledgeSource.Status.State, + ThreadID: remoteKnowledgeSource.Status.ThreadName, + RunID: remoteKnowledgeSource.Status.RunName, + Status: remoteKnowledgeSource.Status.Status, + Error: remoteKnowledgeSource.Status.Error, + } +} diff --git a/pkg/api/handlers/workflows.go b/pkg/api/handlers/workflows.go index 0a96727d..543c2073 100644 --- a/pkg/api/handlers/workflows.go +++ b/pkg/api/handlers/workflows.go @@ -202,24 +202,24 @@ func (a *WorkflowHandler) IngestKnowledge(req api.Context) error { return ingestKnowledge(req, a.workspaceClient, wf.Status.KnowledgeWorkspaceName) } -func (a *WorkflowHandler) CreateOnedriveLinks(req api.Context) error { - return createOneDriveLinks(req, req.PathValue("workflow_id"), new(v1.Workflow)) +func (a *WorkflowHandler) CreateRemoteKnowledgeSource(req api.Context) error { + return createRemoteKnowledgeSource(req, req.PathValue("workflow_id"), new(v1.Workflow)) } -func (a *WorkflowHandler) UpdateOnedriveLinks(req api.Context) error { - return updateOneDriveLinks(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) +func (a *WorkflowHandler) UpdateRemoteKnowledgeSource(req api.Context) error { + return updateRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) } -func (a *WorkflowHandler) ReSyncOnedriveLinks(req api.Context) error { - return reSyncOneDriveLinks(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) +func (a *WorkflowHandler) ReSyncRemoteKnowledgeSource(req api.Context) error { + return reSyncRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) } -func (a *WorkflowHandler) GetOnedriveLinks(req api.Context) error { - return getOneDriveLinksForParent(req, req.PathValue("workflow_id"), new(v1.Workflow)) +func (a *WorkflowHandler) GetRemoteKnowledgeSources(req api.Context) error { + return getRemoteKnowledgeSourceForParent(req, req.PathValue("workflow_id"), new(v1.Workflow)) } -func (a *WorkflowHandler) DeleteOnedriveLinks(req api.Context) error { - return deleteOneDriveLinks(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) +func (a *WorkflowHandler) DeleteRemoteKnowledgeSource(req api.Context) error { + return deleteRemoteKnowledgeSource(req, req.PathValue("id"), req.PathValue("workflow_id"), new(v1.Workflow)) } func (a *WorkflowHandler) Script(req api.Context) error { diff --git a/pkg/api/router/router.go b/pkg/api/router/router.go index 8827db34..53237f81 100644 --- a/pkg/api/router/router.go +++ b/pkg/api/router/router.go @@ -38,11 +38,11 @@ func Router(services *services.Services) (http.Handler, error) { mux.Handle("POST /agents/{id}/knowledge/{file}", w(agents.UploadKnowledge)) mux.Handle("DELETE /agents/{id}/knowledge/{file...}", w(agents.DeleteKnowledge)) - mux.Handle("POST /agents/{agent_id}/onedrive-links", w(agents.CreateOnedriveLinks)) - mux.Handle("GET /agents/{agent_id}/onedrive-links", w(agents.GetOnedriveLinks)) - mux.Handle("PATCH /agents/{agent_id}/onedrive-links/{id}", w(agents.ReSyncOnedriveLinks)) - mux.Handle("PUT /agents/{agent_id}/onedrive-links/{id}", w(agents.UpdateOnedriveLinks)) - mux.Handle("DELETE /agents/{agent_id}/onedrive-links/{id}", w(agents.DeleteOnedriveLinks)) + mux.Handle("POST /agents/{agent_id}/remote-knowledge-source", w(agents.CreateRemoteKnowledgeSource)) + mux.Handle("GET /agents/{agent_id}/remote-knowledge-source", w(agents.GetRemoteKnowledgeSources)) + mux.Handle("PATCH /agents/{agent_id}/remote-knowledge-source/{id}", w(agents.ReSyncRemoteKnowledgeSource)) + mux.Handle("PUT /agents/{agent_id}/remote-knowledge-source/{id}", w(agents.UpdateRemoteKnowledgeSource)) + mux.Handle("DELETE /agents/{agent_id}/remote-knowledge-source/{id}", w(agents.DeleteRemoteKnowledgeSource)) // Workflows mux.Handle("GET /workflows", w(workflows.List)) @@ -63,11 +63,11 @@ func Router(services *services.Services) (http.Handler, error) { mux.Handle("POST /workflows/{id}/knowledge/{file}", w(workflows.UploadKnowledge)) mux.Handle("DELETE /workflows/{id}/knowledge/{file...}", w(workflows.DeleteKnowledge)) - mux.Handle("POST /workflows/{workflow_id}/onedrive-links", w(workflows.CreateOnedriveLinks)) - mux.Handle("GET /workflows/{workflow_id}/onedrive-links", w(workflows.GetOnedriveLinks)) - mux.Handle("PATCH /workflows/{workflow_id}/onedrive-links/{id}", w(workflows.ReSyncOnedriveLinks)) - mux.Handle("PUT /workflows/{workflow_id}/onedrive-links/{id}", w(workflows.UpdateOnedriveLinks)) - mux.Handle("DELETE /workflows/{workflow_id}/onedrive-links/{id}", w(workflows.DeleteOnedriveLinks)) + mux.Handle("POST /workflows/{workflow_id}/remote-knowledge-source", w(workflows.CreateRemoteKnowledgeSource)) + mux.Handle("GET /workflows/{workflow_id}/remote-knowledge-sources", w(workflows.GetRemoteKnowledgeSources)) + mux.Handle("PATCH /workflows/{workflow_id}/remote-knowledge-source/{id}", w(workflows.ReSyncRemoteKnowledgeSource)) + mux.Handle("PUT /workflows/{workflow_id}/remote-knowledge-source/{id}", w(workflows.UpdateRemoteKnowledgeSource)) + mux.Handle("DELETE /workflows/{workflow_id}/remote-knowledge-source/{id}", w(workflows.DeleteRemoteKnowledgeSource)) // Invoker mux.Handle("POST /invoke/{id}", w(invoker.Invoke)) diff --git a/pkg/controller/handlers/uploads/onedrive.go b/pkg/controller/handlers/uploads/remoteknowledgesource.go similarity index 68% rename from pkg/controller/handlers/uploads/onedrive.go rename to pkg/controller/handlers/uploads/remoteknowledgesource.go index 197d60f3..a15d062c 100644 --- a/pkg/controller/handlers/uploads/onedrive.go +++ b/pkg/controller/handlers/uploads/remoteknowledgesource.go @@ -26,18 +26,22 @@ import ( ) type UploadHandler struct { - invoker *invoke.Invoker - workspaceClient *wclient.Client - workspaceProvider string - onedriveTool string + invoker *invoke.Invoker + workspaceClient *wclient.Client + workspaceProvider string + onedriveTool string + notionTool string + websiteCrawlingTool string } -func New(invoker *invoke.Invoker, wc *wclient.Client, workspaceProvider, onedriveTool string) *UploadHandler { +func New(invoker *invoke.Invoker, wc *wclient.Client, workspaceProvider, onedriveTool, notionTool, websiteCrawlingTool string) *UploadHandler { return &UploadHandler{ - invoker: invoker, - workspaceClient: wc, - workspaceProvider: workspaceProvider, - onedriveTool: onedriveTool, + invoker: invoker, + workspaceClient: wc, + workspaceProvider: workspaceProvider, + onedriveTool: onedriveTool, + notionTool: notionTool, + websiteCrawlingTool: websiteCrawlingTool, } } @@ -45,12 +49,12 @@ func New(invoker *invoke.Invoker, wc *wclient.Client, workspaceProvider, onedriv // connector. This will check to ensure an ingestion is not currently running to avoid adding files to a directory that // is currently being ingested. func (u *UploadHandler) CreateThread(req router.Request, _ router.Response) error { - oneDriveLinks := req.Object.(*v1.OneDriveLinks) - if oneDriveLinks.Status.ThreadName != "" { + remoteKnowledgeSource := req.Object.(*v1.RemoteKnowledgeSource) + if remoteKnowledgeSource.Status.ThreadName != "" { return nil } - ws, err := knowledgeWorkspaceFromParent(req, oneDriveLinks) + ws, err := knowledgeWorkspaceFromParent(req, remoteKnowledgeSource) if apierrors.IsNotFound(err) { // A not found error indicates that things are getting cleaned up. // Ignore it because the cleanup handler will ensure this object is deleted. @@ -72,9 +76,9 @@ func (u *UploadHandler) CreateThread(req router.Request, _ router.Response) erro var reSyncRequests v1.SyncUploadRequestList if err := req.List(&reSyncRequests, &client.ListOptions{ - Namespace: oneDriveLinks.Namespace, + Namespace: remoteKnowledgeSource.Namespace, FieldSelector: fields.SelectorFromSet(map[string]string{ - "spec.uploadName": oneDriveLinks.Name, + "spec.remoteKnowledgeSourceName": remoteKnowledgeSource.Name, }), }); err != nil { return err @@ -82,7 +86,7 @@ func (u *UploadHandler) CreateThread(req router.Request, _ router.Response) erro var reSyncNeeded bool for _, reSyncRequest := range reSyncRequests.Items { - if reSyncRequest.CreationTimestamp.After(oneDriveLinks.Status.LastReSyncStarted.Time) { + if reSyncRequest.CreationTimestamp.After(remoteKnowledgeSource.Status.LastReSyncStarted.Time) { reSyncNeeded = true break } @@ -102,12 +106,12 @@ func (u *UploadHandler) CreateThread(req router.Request, _ router.Response) erro GenerateName: system.ThreadPrefix, Namespace: req.Namespace, Labels: map[string]string{ - v1.OneDriveLinksLabel: oneDriveLinks.Name, + v1.RemoteKnowledgeSourceLabel: remoteKnowledgeSource.Name, }, }, Spec: v1.ThreadSpec{ - AgentName: oneDriveLinks.Spec.AgentName, - WorkflowName: oneDriveLinks.Spec.WorkflowName, + AgentName: remoteKnowledgeSource.Spec.AgentName, + WorkflowName: remoteKnowledgeSource.Spec.WorkflowName, WorkspaceID: id, }, } @@ -116,39 +120,39 @@ func (u *UploadHandler) CreateThread(req router.Request, _ router.Response) erro return err } - oneDriveLinks.Status.ThreadName = thread.Name + remoteKnowledgeSource.Status.ThreadName = thread.Name return nil } // RunUpload will run the tool for getting the files. It will only run if the thread has been created and set on the status. func (u *UploadHandler) RunUpload(req router.Request, _ router.Response) error { - oneDriveLinks := req.Object.(*v1.OneDriveLinks) + remoteKnowledgeSource := req.Object.(*v1.RemoteKnowledgeSource) - if oneDriveLinks.Status.ThreadName == "" || oneDriveLinks.Status.RunName != "" { + if remoteKnowledgeSource.Status.ThreadName == "" || remoteKnowledgeSource.Status.RunName != "" { // If the thread hasn't been set, or there is already a run in progress, don't do anything. return nil } var thread v1.Thread - if err := req.Get(&thread, oneDriveLinks.Namespace, oneDriveLinks.Status.ThreadName); apierrors.IsNotFound(err) { + if err := req.Get(&thread, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Status.ThreadName); apierrors.IsNotFound(err) { // Might not be in the cache yet. return nil } else if err != nil { return err } - files, err := knowledgeFilesForUploadName(req, oneDriveLinks.Namespace, oneDriveLinks.Name) + files, err := knowledgeFilesForUploadName(req, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Name) if err != nil { return err } // This gets set as the "output" field in the metadata file. It should be the same as what came out of the last run, if any. output := map[string]any{ - "files": compileKnowledgeFilesForOneDriveConnector(files), - "folders": oneDriveLinks.Status.Folders, - "status": oneDriveLinks.Status.Status, - "error": oneDriveLinks.Status.Error, + "files": compileKnowledgeFilesForConnector(files), + "status": remoteKnowledgeSource.Status.Status, + "error": remoteKnowledgeSource.Status.Error, + "state": remoteKnowledgeSource.Status.State, } writer, err := u.workspaceClient.WriteFile(req.Ctx, thread.Spec.WorkspaceID, ".metadata.json") @@ -156,17 +160,15 @@ func (u *UploadHandler) RunUpload(req router.Request, _ router.Response) error { return fmt.Errorf("failed to create metadata file: %w", err) } - ws, err := knowledgeWorkspaceFromParent(req, oneDriveLinks) + ws, err := knowledgeWorkspaceFromParent(req, remoteKnowledgeSource) if err != nil { return fmt.Errorf("failed to get parent status: %w", err) } b, err := json.Marshal(map[string]any{ - "input": map[string]any{ - "sharedLinks": oneDriveLinks.Spec.SharedLinks, - "outputDir": filepath.Join(workspace.GetDir(ws.Status.WorkspaceID), oneDriveLinks.Name), - }, - "output": output, + "input": remoteKnowledgeSource.Spec.Input, + "outputDir": filepath.Join(workspace.GetDir(ws.Status.WorkspaceID), remoteKnowledgeSource.Name), + "output": output, }) if _, err = writer.Write(b); err != nil { @@ -176,7 +178,7 @@ func (u *UploadHandler) RunUpload(req router.Request, _ router.Response) error { return fmt.Errorf("failed to close metadata file: %w", err) } - r, err := u.invoker.SystemActionWithThread(req.Ctx, &thread, u.onedriveTool, "{}") + r, err := u.invoker.SystemActionWithThread(req.Ctx, &thread, u.getTool(remoteKnowledgeSource), "{}") if err != nil { return err } @@ -186,30 +188,43 @@ func (u *UploadHandler) RunUpload(req router.Request, _ router.Response) error { r.Wait() }() - oneDriveLinks.Status.RunName = r.Run.Name - oneDriveLinks.Status.LastReSyncStarted = metav1.Now() + remoteKnowledgeSource.Status.RunName = r.Run.Name + remoteKnowledgeSource.Status.LastReSyncStarted = metav1.Now() return nil } +func (u *UploadHandler) getTool(r *v1.RemoteKnowledgeSource) string { + switch r.Spec.Input.SourceType { + case types.RemoteKnowledgeSourceTypeOneDrive: + return u.onedriveTool + case types.RemoteKnowledgeSourceTypeNotion: + return u.notionTool + case types.RemoteKnowledgeSourceTypeWebsite: + return u.websiteCrawlingTool + default: + return "" + } +} + // HandleUploadRun will read the output metadata from the connector tool once the run is finished. It will populate the // FileDetails for each file downloaded, and create or update the knowledge metadata file in the parent's knowledge // workspace. It will only process if the run has been created and set on the status. func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response) error { - oneDriveLinks := req.Object.(*v1.OneDriveLinks) + remoteKnowledgeSource := req.Object.(*v1.RemoteKnowledgeSource) - if oneDriveLinks.Status.RunName == "" { + if remoteKnowledgeSource.Status.RunName == "" { return nil } var run v1.Run - if err := req.Get(&run, oneDriveLinks.Namespace, oneDriveLinks.Status.RunName); apierrors.IsNotFound(err) { + if err := req.Get(&run, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Status.RunName); apierrors.IsNotFound(err) { return nil } else if err != nil { return err } var thread v1.Thread - if err := req.Get(&thread, oneDriveLinks.Namespace, oneDriveLinks.Status.ThreadName); err != nil { + if err := req.Get(&thread, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Status.ThreadName); err != nil { return err } @@ -220,17 +235,20 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response } defer file.Close() - var output map[string]v1.OneDriveLinksConnectorStatus - if err = json.NewDecoder(file).Decode(&output); err != nil { + var metadata struct { + Output v1.RemoteConnectorStatus `json:"output,omitempty"` + } + if err = json.NewDecoder(file).Decode(&metadata); err != nil { return err } - oneDriveLinks.Status.Status = output["output"].Status - oneDriveLinks.Status.Error = output["output"].Error + + remoteKnowledgeSource.Status.Status = metadata.Output.Status + remoteKnowledgeSource.Status.Error = metadata.Output.Error resp.RetryAfter(5 * time.Second) return nil } - ws, err := knowledgeWorkspaceFromParent(req, oneDriveLinks) + ws, err := knowledgeWorkspaceFromParent(req, remoteKnowledgeSource) if err != nil { return err } @@ -241,8 +259,10 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response return fmt.Errorf("failed to open metadata file: %w", err) } - var output map[string]v1.OneDriveLinksConnectorStatus - if err = json.NewDecoder(file).Decode(&output); err != nil { + var metadata struct { + Output v1.RemoteConnectorStatus `json:"output"` + } + if err = json.NewDecoder(file).Decode(&metadata); err != nil { return fmt.Errorf("failed to decode metadata file: %w", err) } @@ -250,17 +270,17 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response return fmt.Errorf("failed to close metadata file: %w", err) } - fileMetadata, knowledgeFileNamesFromOutput, err := compileKnowledgeFilesFromOneDriveConnector(req.Ctx, req.Client, oneDriveLinks, output["output"].Files, ws) + fileMetadata, knowledgeFileNamesFromOutput, err := compileKnowledgeFilesFromOneDriveConnector(req.Ctx, req.Client, remoteKnowledgeSource, metadata.Output.Files, ws) if err != nil { return err } - if err = deleteKnowledgeFilesNotIncluded(req.Ctx, req.Client, oneDriveLinks.Namespace, oneDriveLinks.Name, knowledgeFileNamesFromOutput); err != nil { + if err = deleteKnowledgeFilesNotIncluded(req.Ctx, req.Client, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Name, knowledgeFileNamesFromOutput); err != nil { return err } // Put the metadata file in the agent knowledge workspace - writer, err := u.workspaceClient.WriteFile(req.Ctx, ws.Status.WorkspaceID, filepath.Join(oneDriveLinks.Name, ".knowledge.json")) + writer, err := u.workspaceClient.WriteFile(req.Ctx, ws.Status.WorkspaceID, filepath.Join(remoteKnowledgeSource.Name, ".knowledge.json")) if err != nil { return fmt.Errorf("failed to create knowledge metadata file: %w", err) } @@ -271,13 +291,13 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response return fmt.Errorf("failed to close metadata file: %w", err) } - oneDriveLinks.Status.Error = output["output"].Error - oneDriveLinks.Status.Status = output["output"].Status - oneDriveLinks.Status.Folders = output["output"].Folders + remoteKnowledgeSource.Status.Error = metadata.Output.Error + remoteKnowledgeSource.Status.Status = metadata.Output.Status + remoteKnowledgeSource.Status.State = metadata.Output.State // Reset run name to indicate that the run is no longer running - oneDriveLinks.Status.ThreadName = "" - oneDriveLinks.Status.RunName = "" + remoteKnowledgeSource.Status.ThreadName = "" + remoteKnowledgeSource.Status.RunName = "" // Create object to re-ingest knowledge resp.Objects( @@ -301,14 +321,14 @@ func (u *UploadHandler) HandleUploadRun(req router.Request, resp router.Response } func (u *UploadHandler) Cleanup(req router.Request, resp router.Response) error { - onedriveLinks := req.Object.(*v1.OneDriveLinks) + remoteKnowledgeSource := req.Object.(*v1.RemoteKnowledgeSource) // Delete the threads associated with the onedrive links. The runs will be cleaned up by their cleanup handler. var threads v1.ThreadList if err := req.List(&threads, &client.ListOptions{ - Namespace: onedriveLinks.Namespace, + Namespace: remoteKnowledgeSource.Namespace, LabelSelector: labels.SelectorFromSet(map[string]string{ - v1.OneDriveLinksLabel: onedriveLinks.Name, + v1.RemoteKnowledgeSourceLabel: remoteKnowledgeSource.Name, }), }); err != nil { return err @@ -320,7 +340,7 @@ func (u *UploadHandler) Cleanup(req router.Request, resp router.Response) error } } - ws, err := knowledgeWorkspaceFromParent(req, onedriveLinks) + ws, err := knowledgeWorkspaceFromParent(req, remoteKnowledgeSource) if apierrors.IsNotFound(err) { // If the parent object is gone, then other handlers will ensure things are cleaned up. return nil @@ -329,8 +349,8 @@ func (u *UploadHandler) Cleanup(req router.Request, resp router.Response) error } // Delete the directory in the workspace for this onedrive link. - if err := u.workspaceClient.RmDir(req.Ctx, ws.Status.WorkspaceID, onedriveLinks.Name); err != nil { - return fmt.Errorf("failed to delete directory %q in workspace %s: %w", onedriveLinks.Name, ws.Status.WorkspaceID, err) + if err := u.workspaceClient.RmDir(req.Ctx, ws.Status.WorkspaceID, remoteKnowledgeSource.Name); err != nil { + return fmt.Errorf("failed to delete directory %q in workspace %s: %w", remoteKnowledgeSource.Name, ws.Status.WorkspaceID, err) } files, err := u.workspaceClient.Ls(req.Ctx, ws.Status.WorkspaceID) @@ -358,18 +378,18 @@ func (u *UploadHandler) Cleanup(req router.Request, resp router.Response) error return nil } -func knowledgeWorkspaceFromParent(req router.Request, onedriveLinks *v1.OneDriveLinks) (*v1.Workspace, error) { - if onedriveLinks.Spec.AgentName != "" { +func knowledgeWorkspaceFromParent(req router.Request, remoteKnowledgeSource *v1.RemoteKnowledgeSource) (*v1.Workspace, error) { + if remoteKnowledgeSource.Spec.AgentName != "" { var agent v1.Agent - if err := req.Get(&agent, onedriveLinks.Namespace, onedriveLinks.Spec.AgentName); err != nil { + if err := req.Get(&agent, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Spec.AgentName); err != nil { return nil, err } var ws v1.Workspace return &ws, req.Get(&ws, agent.Namespace, agent.Status.KnowledgeWorkspaceName) - } else if onedriveLinks.Spec.WorkflowName != "" { + } else if remoteKnowledgeSource.Spec.WorkflowName != "" { var workflow v1.Workflow - if err := req.Get(&workflow, onedriveLinks.Namespace, onedriveLinks.Spec.WorkflowName); err != nil { + if err := req.Get(&workflow, remoteKnowledgeSource.Namespace, remoteKnowledgeSource.Spec.WorkflowName); err != nil { return nil, err } @@ -377,18 +397,18 @@ func knowledgeWorkspaceFromParent(req router.Request, onedriveLinks *v1.OneDrive return &ws, req.Get(&ws, workflow.Namespace, workflow.Status.KnowledgeWorkspaceName) } - return nil, fmt.Errorf("no parent object found for onedrive link %q", onedriveLinks.Name) + return nil, fmt.Errorf("no parent object found for onedrive link %q", remoteKnowledgeSource.Name) } func knowledgeFilesForUploadName(req router.Request, namespace, name string) (v1.KnowledgeFileList, error) { var files v1.KnowledgeFileList return files, req.List(&files, &client.ListOptions{ - FieldSelector: fields.SelectorFromSet(map[string]string{"spec.uploadName": name}), + FieldSelector: fields.SelectorFromSet(map[string]string{"spec.remoteKnowledgeSourceName": name}), Namespace: namespace, }) } -func compileKnowledgeFilesFromOneDriveConnector(ctx context.Context, c client.Client, oneDriveLinks *v1.OneDriveLinks, files map[string]types.FileDetails, ws *v1.Workspace) (map[string]any, map[string]struct{}, error) { +func compileKnowledgeFilesFromOneDriveConnector(ctx context.Context, c client.Client, remoteKnowledgeSource *v1.RemoteKnowledgeSource, files map[string]types.FileDetails, ws *v1.Workspace) (map[string]any, map[string]struct{}, error) { var ( errs []error // fileMetadata is the metadata for the knowledge tool, translated from the connector output. @@ -411,12 +431,13 @@ func compileKnowledgeFilesFromOneDriveConnector(ctx context.Context, c client.Cl newKnowledgeFile := &v1.KnowledgeFile{ ObjectMeta: metav1.ObjectMeta{ Name: name, - Namespace: oneDriveLinks.Namespace, + Namespace: remoteKnowledgeSource.Namespace, }, Spec: v1.KnowledgeFileSpec{ - WorkspaceName: ws.Name, - FileName: fileRelPath, - UploadName: oneDriveLinks.Name, + WorkspaceName: ws.Name, + FileName: fileRelPath, + RemoteKnowledgeSourceName: remoteKnowledgeSource.Name, + RemoteKnowledgeSourceType: remoteKnowledgeSource.Spec.Input.SourceType, }, } if err := c.Create(ctx, newKnowledgeFile); err == nil || apierrors.IsAlreadyExists(err) { @@ -452,7 +473,7 @@ func deleteKnowledgeFilesNotIncluded(ctx context.Context, c client.Client, names var knowledgeFiles v1.KnowledgeFileList if err := c.List(ctx, uncached.List(&knowledgeFiles), &client.ListOptions{ Namespace: namespace, - FieldSelector: fields.SelectorFromSet(map[string]string{"spec.uploadName": name}), + FieldSelector: fields.SelectorFromSet(map[string]string{"spec.remoteKnowledgeSourceName": name}), }); err != nil { return fmt.Errorf("failed to list knowledge files: %w", err) } @@ -469,7 +490,7 @@ func deleteKnowledgeFilesNotIncluded(ctx context.Context, c client.Client, names return errors.Join(errs...) } -func compileKnowledgeFilesForOneDriveConnector(files v1.KnowledgeFileList) map[string]types.FileDetails { +func compileKnowledgeFilesForConnector(files v1.KnowledgeFileList) map[string]types.FileDetails { knowledgeFileStatuses := make(map[string]types.FileDetails, len(files.Items)) for _, file := range files.Items { knowledgeFileStatuses[file.Status.UploadID] = file.Status.FileDetails diff --git a/pkg/controller/handlers/uploads/syncrequests.go b/pkg/controller/handlers/uploads/syncrequests.go index 2d8ea8be..4684613a 100644 --- a/pkg/controller/handlers/uploads/syncrequests.go +++ b/pkg/controller/handlers/uploads/syncrequests.go @@ -10,9 +10,9 @@ import ( func (u *UploadHandler) CleanupSyncRequests(req router.Request, _ router.Response) error { reSyncUploadRequest := req.Object.(*v1.SyncUploadRequest) - var upload v1.OneDriveLinks + var upload v1.RemoteKnowledgeSource // Use !Before here for checking time because the lastReSyncStarted time and the sync request maybe the at the same second. - if err := req.Get(&upload, reSyncUploadRequest.Namespace, reSyncUploadRequest.Spec.UploadName); apierrors.IsNotFound(err) || err == nil && !upload.Status.LastReSyncStarted.Before(&reSyncUploadRequest.CreationTimestamp) { + if err := req.Get(&upload, reSyncUploadRequest.Namespace, reSyncUploadRequest.Spec.RemoteKnowledgeSourceName); apierrors.IsNotFound(err) || err == nil && !upload.Status.LastReSyncStarted.Before(&reSyncUploadRequest.CreationTimestamp) { return kclient.IgnoreNotFound(req.Client.Delete(req.Ctx, reSyncUploadRequest)) } else if err != nil { return err diff --git a/pkg/controller/routes.go b/pkg/controller/routes.go index debfdbc3..853c18a0 100644 --- a/pkg/controller/routes.go +++ b/pkg/controller/routes.go @@ -29,7 +29,7 @@ func routes(root *router.Router, svcs *services.Services) error { threads := threads.New(svcs.AIHelper) workspace := workspace.New(svcs.WorkspaceClient, "directory") knowledge := knowledgehandler.New(svcs.WorkspaceClient, ingester, "directory") - uploads := uploads.New(svcs.Invoker, svcs.WorkspaceClient, "directory", svcs.SystemTools[services.SystemToolOneDrive]) + uploads := uploads.New(svcs.Invoker, svcs.WorkspaceClient, "directory", svcs.SystemTools[services.SystemToolOneDrive], svcs.SystemTools[services.SystemToolNotion], svcs.SystemTools[services.SystemToolWebsite]) runs := runs.New(svcs.Invoker) webhookExecutions := webhookexecution.New(svcs.WorkspaceClient, svcs.Invoker) @@ -68,11 +68,11 @@ func routes(root *router.Router, svcs *services.Services) error { root.Type(&v1.Agent{}).HandlerFunc(agents.WorkspaceObjects) // Uploads - root.Type(&v1.OneDriveLinks{}).HandlerFunc(uploads.CreateThread) - root.Type(&v1.OneDriveLinks{}).HandlerFunc(uploads.RunUpload) - root.Type(&v1.OneDriveLinks{}).HandlerFunc(uploads.HandleUploadRun) - root.Type(&v1.OneDriveLinks{}).HandlerFunc(cleanup.Cleanup) - root.Type(&v1.OneDriveLinks{}).FinalizeFunc(v1.OneDriveLinksFinalizer, uploads.Cleanup) + root.Type(&v1.RemoteKnowledgeSource{}).HandlerFunc(uploads.CreateThread) + root.Type(&v1.RemoteKnowledgeSource{}).HandlerFunc(uploads.RunUpload) + root.Type(&v1.RemoteKnowledgeSource{}).HandlerFunc(uploads.HandleUploadRun) + root.Type(&v1.RemoteKnowledgeSource{}).HandlerFunc(cleanup.Cleanup) + root.Type(&v1.RemoteKnowledgeSource{}).FinalizeFunc(v1.RemoteKnowledgeSourceFinalizer, uploads.Cleanup) // ReSync requests root.Type(&v1.SyncUploadRequest{}).HandlerFunc(uploads.CleanupSyncRequests) diff --git a/pkg/services/config.go b/pkg/services/config.go index 0a2b716d..2d7b08cc 100644 --- a/pkg/services/config.go +++ b/pkg/services/config.go @@ -34,6 +34,8 @@ import ( const ( SystemToolKnowledge = "knowledge" SystemToolOneDrive = "onedrive" + SystemToolNotion = "notion" + SystemToolWebsite = "website" ) type Config struct { @@ -135,6 +137,8 @@ func New(ctx context.Context, config Config) (*Services, error) { SystemTools: map[string]string{ SystemToolKnowledge: config.KnowledgeTool, SystemToolOneDrive: config.OneDriveTool, + SystemToolWebsite: config.WebsiteTool, + SystemToolNotion: config.NotionTool, }, AIHelper: aihelper.New(c, config.HelperModel), }, nil diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/file.go b/pkg/storage/apis/otto.gptscript.ai/v1/file.go index e0b26a7c..4bea8edb 100644 --- a/pkg/storage/apis/otto.gptscript.ai/v1/file.go +++ b/pkg/storage/apis/otto.gptscript.ai/v1/file.go @@ -22,7 +22,7 @@ type KnowledgeFile struct { func (k *KnowledgeFile) DeleteRefs() []Ref { return []Ref{ {ObjType: new(Workspace), Name: k.Spec.WorkspaceName}, - {ObjType: new(OneDriveLinks), Name: k.Spec.UploadName}, + {ObjType: new(RemoteKnowledgeSource), Name: k.Spec.RemoteKnowledgeSourceName}, } } @@ -38,23 +38,26 @@ func (k *KnowledgeFile) Get(field string) string { switch field { case "spec.workspaceName": return k.Spec.WorkspaceName - case "spec.uploadName": - return k.Spec.UploadName + case "spec.remoteKnowledgeSourceName": + return k.Spec.RemoteKnowledgeSourceName + case "spec.remoteKnowledgeSourceType": + return string(k.Spec.RemoteKnowledgeSourceType) } return "" } func (*KnowledgeFile) FieldNames() []string { - return []string{"spec.workspaceName", "spec.uploadName"} + return []string{"spec.workspaceName", "spec.remoteKnowledgeSourceName", "spec.remoteKnowledgeSourceType"} } var _ fields.Fields = (*KnowledgeFile)(nil) type KnowledgeFileSpec struct { - FileName string `json:"fileName"` - WorkspaceName string `json:"workspaceName,omitempty"` - UploadName string `json:"uploadName,omitempty"` + FileName string `json:"fileName"` + WorkspaceName string `json:"workspaceName,omitempty"` + RemoteKnowledgeSourceName string `json:"remoteKnowledgeSourceName,omitempty"` + RemoteKnowledgeSourceType types.RemoteKnowledgeSourceType `json:"remoteKnowledgeSourceType,omitempty"` } type KnowledgeFileStatus struct { diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/remoteknowledgesource.go b/pkg/storage/apis/otto.gptscript.ai/v1/remoteknowledgesource.go new file mode 100644 index 00000000..e00bc537 --- /dev/null +++ b/pkg/storage/apis/otto.gptscript.ai/v1/remoteknowledgesource.go @@ -0,0 +1,115 @@ +package v1 + +import ( + "github.com/acorn-io/baaah/pkg/conditions" + "github.com/gptscript-ai/otto/apiclient/types" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/fields" +) + +const ( + RemoteKnowledgeSourceFinalizer = "otto.gptscript.ai/remote-knowledge-source" + RemoteKnowledgeSourceLabel = "otto.gptscript.ai/remote-knowledge-source" +) + +var ( + _ conditions.Conditions = (*RemoteKnowledgeSource)(nil) + _ fields.Fields = (*SyncUploadRequest)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type RemoteKnowledgeSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec RemoteKnowledgeSourceSpec `json:"spec,omitempty"` + Status RemoteKnowledgeSourceStatus `json:"status,omitempty"` +} + +func (in *RemoteKnowledgeSource) DeleteRefs() []Ref { + return []Ref{ + {ObjType: &Agent{}, Name: in.Spec.AgentName}, + {ObjType: &Workflow{}, Name: in.Spec.WorkflowName}, + } +} + +func (in *RemoteKnowledgeSource) GetConditions() *[]metav1.Condition { + return &in.Status.Conditions +} + +type RemoteKnowledgeSourceSpec struct { + AgentName string `json:"agentName,omitempty"` + WorkflowName string `json:"workflowName,omitempty"` + Input types.RemoteKnowledgeSourceInput `json:"input,omitempty"` +} + +type RemoteKnowledgeSourceStatus struct { + Conditions []metav1.Condition `json:"conditions,omitempty"` + ThreadName string `json:"threadName,omitempty"` + RunName string `json:"runName,omitempty"` + Status string `json:"status,omitempty"` + Error string `json:"error,omitempty"` + State types.RemoteKnowledgeSourceState `json:"state,omitempty"` + LastReSyncStarted metav1.Time `json:"lastReSyncStarted,omitempty"` +} + +type RemoteConnectorStatus struct { + Status string `json:"status,omitempty"` + Error string `json:"error,omitempty"` + Files map[string]types.FileDetails `json:"files,omitempty"` + State types.RemoteKnowledgeSourceState `json:"state,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type RemoteKnowledgeSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []RemoteKnowledgeSource `json:"items"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type SyncUploadRequest struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec SyncUploadRequestSpec `json:"spec,omitempty"` + Status SyncUploadRequestStatus `json:"status,omitempty"` +} + +func (in *SyncUploadRequest) Has(field string) bool { + return in.Get(field) != "" +} + +func (in *SyncUploadRequest) Get(field string) string { + if in == nil { + return "" + } + + switch field { + case "spec.remoteKnowledgeSourceName": + return in.Spec.RemoteKnowledgeSourceName + } + + return "" +} + +func (*SyncUploadRequest) FieldNames() []string { + return []string{"spec.remoteKnowledgeSourceName"} +} + +type SyncUploadRequestSpec struct { + RemoteKnowledgeSourceName string `json:"remoteKnowledgeSourceName,omitempty"` +} + +type SyncUploadRequestStatus struct{} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type SyncUploadRequestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SyncUploadRequest `json:"items"` +} diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/scheme.go b/pkg/storage/apis/otto.gptscript.ai/v1/scheme.go index 889d1c1a..4648cb20 100644 --- a/pkg/storage/apis/otto.gptscript.ai/v1/scheme.go +++ b/pkg/storage/apis/otto.gptscript.ai/v1/scheme.go @@ -37,8 +37,8 @@ func AddToSchemeWithGV(scheme *runtime.Scheme, schemeGroupVersion schema.GroupVe &WorkflowExecutionList{}, &WorkflowStep{}, &WorkflowStepList{}, - &OneDriveLinks{}, - &OneDriveLinksList{}, + &RemoteKnowledgeSource{}, + &RemoteKnowledgeSourceList{}, &KnowledgeFile{}, &KnowledgeFileList{}, &ToolReference{}, diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/upload.go b/pkg/storage/apis/otto.gptscript.ai/v1/upload.go deleted file mode 100644 index 59f4755b..00000000 --- a/pkg/storage/apis/otto.gptscript.ai/v1/upload.go +++ /dev/null @@ -1,115 +0,0 @@ -package v1 - -import ( - "github.com/acorn-io/baaah/pkg/conditions" - "github.com/gptscript-ai/otto/apiclient/types" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/fields" -) - -const ( - OneDriveLinksFinalizer = "otto.gptscript.ai/onedrive-links" - OneDriveLinksLabel = "otto.gptscript.ai/onedrive-links" -) - -var ( - _ conditions.Conditions = (*OneDriveLinks)(nil) - _ fields.Fields = (*SyncUploadRequest)(nil) -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type OneDriveLinks struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec OnedriveLinksSpec `json:"spec,omitempty"` - Status OnedriveLinksStatus `json:"status,omitempty"` -} - -func (in *OneDriveLinks) DeleteRefs() []Ref { - return []Ref{ - {ObjType: &Agent{}, Name: in.Spec.AgentName}, - {ObjType: &Workflow{}, Name: in.Spec.WorkflowName}, - } -} - -func (in *OneDriveLinks) GetConditions() *[]metav1.Condition { - return &in.Status.Conditions -} - -type OnedriveLinksSpec struct { - AgentName string `json:"agentName,omitempty"` - WorkflowName string `json:"workflowName,omitempty"` - SharedLinks []string `json:"sharedLinks,omitempty"` -} - -type OnedriveLinksStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty"` - ThreadName string `json:"threadName,omitempty"` - RunName string `json:"runName,omitempty"` - Status string `json:"status,omitempty"` - Error string `json:"error,omitempty"` - Folders types.FolderSet `json:"folders,omitempty"` - LastReSyncStarted metav1.Time `json:"lastReSyncStarted,omitempty"` -} - -type OneDriveLinksConnectorStatus struct { - Status string `json:"status,omitempty"` - Error string `json:"error,omitempty"` - Files map[string]types.FileDetails `json:"files,omitempty"` - Folders types.FolderSet `json:"folders,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type OneDriveLinksList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - - Items []OneDriveLinks `json:"items"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type SyncUploadRequest struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec SyncUploadRequestSpec `json:"spec,omitempty"` - Status SyncUploadRequestStatus `json:"status,omitempty"` -} - -func (in *SyncUploadRequest) Has(field string) bool { - return in.Get(field) != "" -} - -func (in *SyncUploadRequest) Get(field string) string { - if in == nil { - return "" - } - - switch field { - case "spec.uploadName": - return in.Spec.UploadName - } - - return "" -} - -func (*SyncUploadRequest) FieldNames() []string { - return []string{"spec.uploadName"} -} - -type SyncUploadRequestSpec struct { - UploadName string `json:"uploadName,omitempty"` -} - -type SyncUploadRequestStatus struct{} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type SyncUploadRequestList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []SyncUploadRequest `json:"items"` -} diff --git a/pkg/storage/apis/otto.gptscript.ai/v1/zz_generated.deepcopy.go b/pkg/storage/apis/otto.gptscript.ai/v1/zz_generated.deepcopy.go index 080c68c9..0401875f 100644 --- a/pkg/storage/apis/otto.gptscript.ai/v1/zz_generated.deepcopy.go +++ b/pkg/storage/apis/otto.gptscript.ai/v1/zz_generated.deepcopy.go @@ -295,26 +295,26 @@ func (in *KnowledgeFileStatus) DeepCopy() *KnowledgeFileStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OneDriveLinks) DeepCopyInto(out *OneDriveLinks) { +func (in *Reference) DeepCopyInto(out *Reference) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) + out.Spec = in.Spec in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinks. -func (in *OneDriveLinks) DeepCopy() *OneDriveLinks { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reference. +func (in *Reference) DeepCopy() *Reference { if in == nil { return nil } - out := new(OneDriveLinks) + out := new(Reference) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OneDriveLinks) DeepCopyObject() runtime.Object { +func (in *Reference) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -322,60 +322,31 @@ func (in *OneDriveLinks) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OneDriveLinksConnectorStatus) DeepCopyInto(out *OneDriveLinksConnectorStatus) { - *out = *in - if in.Files != nil { - in, out := &in.Files, &out.Files - *out = make(map[string]types.FileDetails, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.Folders != nil { - in, out := &in.Folders, &out.Folders - *out = make(types.FolderSet, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinksConnectorStatus. -func (in *OneDriveLinksConnectorStatus) DeepCopy() *OneDriveLinksConnectorStatus { - if in == nil { - return nil - } - out := new(OneDriveLinksConnectorStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OneDriveLinksList) DeepCopyInto(out *OneDriveLinksList) { +func (in *ReferenceList) DeepCopyInto(out *ReferenceList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]OneDriveLinks, len(*in)) + *out = make([]Reference, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OneDriveLinksList. -func (in *OneDriveLinksList) DeepCopy() *OneDriveLinksList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceList. +func (in *ReferenceList) DeepCopy() *ReferenceList { if in == nil { return nil } - out := new(OneDriveLinksList) + out := new(ReferenceList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OneDriveLinksList) DeepCopyObject() runtime.Object { +func (in *ReferenceList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -383,27 +354,22 @@ func (in *OneDriveLinksList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OnedriveLinksSpec) DeepCopyInto(out *OnedriveLinksSpec) { +func (in *ReferenceSpec) DeepCopyInto(out *ReferenceSpec) { *out = *in - if in.SharedLinks != nil { - in, out := &in.SharedLinks, &out.SharedLinks - *out = make([]string, len(*in)) - copy(*out, *in) - } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OnedriveLinksSpec. -func (in *OnedriveLinksSpec) DeepCopy() *OnedriveLinksSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceSpec. +func (in *ReferenceSpec) DeepCopy() *ReferenceSpec { if in == nil { return nil } - out := new(OnedriveLinksSpec) + out := new(ReferenceSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OnedriveLinksStatus) DeepCopyInto(out *OnedriveLinksStatus) { +func (in *ReferenceStatus) DeepCopyInto(out *ReferenceStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions @@ -412,47 +378,62 @@ func (in *OnedriveLinksStatus) DeepCopyInto(out *OnedriveLinksStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.Folders != nil { - in, out := &in.Folders, &out.Folders - *out = make(types.FolderSet, len(*in)) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceStatus. +func (in *ReferenceStatus) DeepCopy() *ReferenceStatus { + if in == nil { + return nil + } + out := new(ReferenceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteConnectorStatus) DeepCopyInto(out *RemoteConnectorStatus) { + *out = *in + if in.Files != nil { + in, out := &in.Files, &out.Files + *out = make(map[string]types.FileDetails, len(*in)) for key, val := range *in { (*out)[key] = val } } - in.LastReSyncStarted.DeepCopyInto(&out.LastReSyncStarted) + in.State.DeepCopyInto(&out.State) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OnedriveLinksStatus. -func (in *OnedriveLinksStatus) DeepCopy() *OnedriveLinksStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteConnectorStatus. +func (in *RemoteConnectorStatus) DeepCopy() *RemoteConnectorStatus { if in == nil { return nil } - out := new(OnedriveLinksStatus) + out := new(RemoteConnectorStatus) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Reference) DeepCopyInto(out *Reference) { +func (in *RemoteKnowledgeSource) DeepCopyInto(out *RemoteKnowledgeSource) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reference. -func (in *Reference) DeepCopy() *Reference { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSource. +func (in *RemoteKnowledgeSource) DeepCopy() *RemoteKnowledgeSource { if in == nil { return nil } - out := new(Reference) + out := new(RemoteKnowledgeSource) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Reference) DeepCopyObject() runtime.Object { +func (in *RemoteKnowledgeSource) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -460,31 +441,31 @@ func (in *Reference) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReferenceList) DeepCopyInto(out *ReferenceList) { +func (in *RemoteKnowledgeSourceList) DeepCopyInto(out *RemoteKnowledgeSourceList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Reference, len(*in)) + *out = make([]RemoteKnowledgeSource, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceList. -func (in *ReferenceList) DeepCopy() *ReferenceList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceList. +func (in *RemoteKnowledgeSourceList) DeepCopy() *RemoteKnowledgeSourceList { if in == nil { return nil } - out := new(ReferenceList) + out := new(RemoteKnowledgeSourceList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ReferenceList) DeepCopyObject() runtime.Object { +func (in *RemoteKnowledgeSourceList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -492,22 +473,23 @@ func (in *ReferenceList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReferenceSpec) DeepCopyInto(out *ReferenceSpec) { +func (in *RemoteKnowledgeSourceSpec) DeepCopyInto(out *RemoteKnowledgeSourceSpec) { *out = *in + in.Input.DeepCopyInto(&out.Input) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceSpec. -func (in *ReferenceSpec) DeepCopy() *ReferenceSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceSpec. +func (in *RemoteKnowledgeSourceSpec) DeepCopy() *RemoteKnowledgeSourceSpec { if in == nil { return nil } - out := new(ReferenceSpec) + out := new(RemoteKnowledgeSourceSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ReferenceStatus) DeepCopyInto(out *ReferenceStatus) { +func (in *RemoteKnowledgeSourceStatus) DeepCopyInto(out *RemoteKnowledgeSourceStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions @@ -516,14 +498,16 @@ func (in *ReferenceStatus) DeepCopyInto(out *ReferenceStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + in.State.DeepCopyInto(&out.State) + in.LastReSyncStarted.DeepCopyInto(&out.LastReSyncStarted) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReferenceStatus. -func (in *ReferenceStatus) DeepCopy() *ReferenceStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteKnowledgeSourceStatus. +func (in *RemoteKnowledgeSourceStatus) DeepCopy() *RemoteKnowledgeSourceStatus { if in == nil { return nil } - out := new(ReferenceStatus) + out := new(RemoteKnowledgeSourceStatus) in.DeepCopyInto(out) return out } diff --git a/pkg/storage/openapi/generated/openapi_generated.go b/pkg/storage/openapi/generated/openapi_generated.go index 996f78ce..59f4caa4 100644 --- a/pkg/storage/openapi/generated/openapi_generated.go +++ b/pkg/storage/openapi/generated/openapi_generated.go @@ -34,10 +34,17 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/gptscript-ai/otto/apiclient/types.KnowledgeFile": schema_gptscript_ai_otto_apiclient_types_KnowledgeFile(ref), "github.com/gptscript-ai/otto/apiclient/types.KnowledgeFileList": schema_gptscript_ai_otto_apiclient_types_KnowledgeFileList(ref), "github.com/gptscript-ai/otto/apiclient/types.Metadata": schema_gptscript_ai_otto_apiclient_types_Metadata(ref), - "github.com/gptscript-ai/otto/apiclient/types.OneDriveLinks": schema_gptscript_ai_otto_apiclient_types_OneDriveLinks(ref), - "github.com/gptscript-ai/otto/apiclient/types.OneDriveLinksList": schema_gptscript_ai_otto_apiclient_types_OneDriveLinksList(ref), + "github.com/gptscript-ai/otto/apiclient/types.NotionConfig": schema_gptscript_ai_otto_apiclient_types_NotionConfig(ref), + "github.com/gptscript-ai/otto/apiclient/types.NotionConnectorState": schema_gptscript_ai_otto_apiclient_types_NotionConnectorState(ref), + "github.com/gptscript-ai/otto/apiclient/types.NotionPage": schema_gptscript_ai_otto_apiclient_types_NotionPage(ref), + "github.com/gptscript-ai/otto/apiclient/types.OneDriveConfig": schema_gptscript_ai_otto_apiclient_types_OneDriveConfig(ref), + "github.com/gptscript-ai/otto/apiclient/types.OneDriveLinksConnectorState": schema_gptscript_ai_otto_apiclient_types_OneDriveLinksConnectorState(ref), "github.com/gptscript-ai/otto/apiclient/types.Progress": schema_gptscript_ai_otto_apiclient_types_Progress(ref), "github.com/gptscript-ai/otto/apiclient/types.Prompt": schema_gptscript_ai_otto_apiclient_types_Prompt(ref), + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSource": schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSource(ref), + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceInput": schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceInput(ref), + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceList": schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceList(ref), + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState": schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceState(ref), "github.com/gptscript-ai/otto/apiclient/types.Run": schema_gptscript_ai_otto_apiclient_types_Run(ref), "github.com/gptscript-ai/otto/apiclient/types.RunList": schema_gptscript_ai_otto_apiclient_types_RunList(ref), "github.com/gptscript-ai/otto/apiclient/types.Step": schema_gptscript_ai_otto_apiclient_types_Step(ref), @@ -56,6 +63,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/gptscript-ai/otto/apiclient/types.WebhookExternalStatus": schema_gptscript_ai_otto_apiclient_types_WebhookExternalStatus(ref), "github.com/gptscript-ai/otto/apiclient/types.WebhookList": schema_gptscript_ai_otto_apiclient_types_WebhookList(ref), "github.com/gptscript-ai/otto/apiclient/types.WebhookManifest": schema_gptscript_ai_otto_apiclient_types_WebhookManifest(ref), + "github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConfig": schema_gptscript_ai_otto_apiclient_types_WebsiteCrawlingConfig(ref), + "github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConnectorState": schema_gptscript_ai_otto_apiclient_types_WebsiteCrawlingConnectorState(ref), "github.com/gptscript-ai/otto/apiclient/types.While": schema_gptscript_ai_otto_apiclient_types_While(ref), "github.com/gptscript-ai/otto/apiclient/types.Workflow": schema_gptscript_ai_otto_apiclient_types_Workflow(ref), "github.com/gptscript-ai/otto/apiclient/types.WorkflowExternalStatus": schema_gptscript_ai_otto_apiclient_types_WorkflowExternalStatus(ref), @@ -73,16 +82,16 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.KnowledgeFileList": schema_storage_apis_ottogptscriptai_v1_KnowledgeFileList(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.KnowledgeFileSpec": schema_storage_apis_ottogptscriptai_v1_KnowledgeFileSpec(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.KnowledgeFileStatus": schema_storage_apis_ottogptscriptai_v1_KnowledgeFileStatus(ref), - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OneDriveLinks": schema_storage_apis_ottogptscriptai_v1_OneDriveLinks(ref), - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OneDriveLinksConnectorStatus": schema_storage_apis_ottogptscriptai_v1_OneDriveLinksConnectorStatus(ref), - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OneDriveLinksList": schema_storage_apis_ottogptscriptai_v1_OneDriveLinksList(ref), - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksSpec": schema_storage_apis_ottogptscriptai_v1_OnedriveLinksSpec(ref), - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksStatus": schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Ref": schema_storage_apis_ottogptscriptai_v1_Ref(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Reference": schema_storage_apis_ottogptscriptai_v1_Reference(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceList": schema_storage_apis_ottogptscriptai_v1_ReferenceList(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceSpec": schema_storage_apis_ottogptscriptai_v1_ReferenceSpec(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceStatus": schema_storage_apis_ottogptscriptai_v1_ReferenceStatus(ref), + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteConnectorStatus": schema_storage_apis_ottogptscriptai_v1_RemoteConnectorStatus(ref), + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSource": schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSource(ref), + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceList": schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceList(ref), + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceSpec": schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceSpec(ref), + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceStatus": schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceStatus(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Run": schema_storage_apis_ottogptscriptai_v1_Run(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RunList": schema_storage_apis_ottogptscriptai_v1_RunList(ref), "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RunSpec": schema_storage_apis_ottogptscriptai_v1_RunSpec(ref), @@ -766,7 +775,13 @@ func schema_gptscript_ai_otto_apiclient_types_KnowledgeFile(ref common.Reference Format: "", }, }, - "uploadID": { + "remoteKnowledgeSourceID": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "remoteKnowledgeSourceType": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -866,31 +881,13 @@ func schema_gptscript_ai_otto_apiclient_types_Metadata(ref common.ReferenceCallb } } -func schema_gptscript_ai_otto_apiclient_types_OneDriveLinks(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_gptscript_ai_otto_apiclient_types_NotionConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "Metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Metadata"), - }, - }, - "agentID": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "workflowID": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "sharedLinks": { + "pages": { SchemaProps: spec.SchemaProps{ Type: []string{"array"}, Items: &spec.SchemaOrArray{ @@ -904,78 +901,115 @@ func schema_gptscript_ai_otto_apiclient_types_OneDriveLinks(ref common.Reference }, }, }, - "threadID": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "runID": { + }, + }, + }, + } +} + +func schema_gptscript_ai_otto_apiclient_types_NotionConnectorState(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pages": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.NotionPage"), + }, + }, + }, }, }, - "status": { + }, + }, + }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.NotionPage"}, + } +} + +func schema_gptscript_ai_otto_apiclient_types_NotionPage(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "url": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", }, }, - "error": { + "title": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", }, }, - "folders": { + }, + }, + }, + } +} + +func schema_gptscript_ai_otto_apiclient_types_OneDriveConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "sharedLinks": { SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Item"), + Default: "", + Type: []string{"string"}, + Format: "", }, }, }, }, }, }, - Required: []string{"Metadata"}, }, }, - Dependencies: []string{ - "github.com/gptscript-ai/otto/apiclient/types.Item", "github.com/gptscript-ai/otto/apiclient/types.Metadata"}, } } -func schema_gptscript_ai_otto_apiclient_types_OneDriveLinksList(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_gptscript_ai_otto_apiclient_types_OneDriveLinksConnectorState(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "items": { + "folders": { SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.OneDriveLinks"), + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Item"), }, }, }, }, }, }, - Required: []string{"items"}, }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/apiclient/types.OneDriveLinks"}, + "github.com/gptscript-ai/otto/apiclient/types.Item"}, } } @@ -1120,6 +1154,181 @@ func schema_gptscript_ai_otto_apiclient_types_Prompt(ref common.ReferenceCallbac } } +func schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Metadata"), + }, + }, + "agentID": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "workflowID": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "threadID": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "runID": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "input": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceInput"), + }, + }, + "state": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"Metadata"}, + }, + }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.Metadata", "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceInput", "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState"}, + } +} + +func schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceInput(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "sourceType": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "exclude": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "onedriveConfig": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.OneDriveConfig"), + }, + }, + "notionConfig": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.NotionConfig"), + }, + }, + "websiteCrawlingConfig": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConfig"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.NotionConfig", "github.com/gptscript-ai/otto/apiclient/types.OneDriveConfig", "github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConfig"}, + } +} + +func schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSource"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSource"}, + } +} + +func schema_gptscript_ai_otto_apiclient_types_RemoteKnowledgeSourceState(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "onedriveState": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.OneDriveLinksConnectorState"), + }, + }, + "notionState": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.NotionConnectorState"), + }, + }, + "websiteCrawlingState": { + SchemaProps: spec.SchemaProps{ + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConnectorState"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.NotionConnectorState", "github.com/gptscript-ai/otto/apiclient/types.OneDriveLinksConnectorState", "github.com/gptscript-ai/otto/apiclient/types.WebsiteCrawlingConnectorState"}, + } +} + func schema_gptscript_ai_otto_apiclient_types_Run(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -1799,10 +2008,75 @@ func schema_gptscript_ai_otto_apiclient_types_WebhookManifest(ref common.Referen Format: "", }, }, - "headers": { + "headers": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "secret": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "validationHeader": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_gptscript_ai_otto_apiclient_types_WebsiteCrawlingConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "urls": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func schema_gptscript_ai_otto_apiclient_types_WebsiteCrawlingConnectorState(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "scrapeJobIds": { SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: "", @@ -1813,21 +2087,26 @@ func schema_gptscript_ai_otto_apiclient_types_WebhookManifest(ref common.Referen }, }, }, - "secret": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "validationHeader": { + "folders": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Item"), + }, + }, + }, }, }, }, + Required: []string{"scrapeJobIds", "folders"}, }, }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.Item"}, } } @@ -2500,7 +2779,13 @@ func schema_storage_apis_ottogptscriptai_v1_KnowledgeFileSpec(ref common.Referen Format: "", }, }, - "uploadName": { + "remoteKnowledgeSourceName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "remoteKnowledgeSourceType": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -2545,107 +2830,80 @@ func schema_storage_apis_ottogptscriptai_v1_KnowledgeFileStatus(ref common.Refer } } -func schema_storage_apis_ottogptscriptai_v1_OneDriveLinks(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_Ref(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { + "ObjType": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksSpec"), + Ref: ref("sigs.k8s.io/controller-runtime/pkg/client.Object"), }, }, - "status": { + "Name": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksStatus"), + Default: "", + Type: []string{"string"}, + Format: "", }, }, }, + Required: []string{"ObjType", "Name"}, }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksSpec", "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OnedriveLinksStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "sigs.k8s.io/controller-runtime/pkg/client.Object"}, } } -func schema_storage_apis_ottogptscriptai_v1_OneDriveLinksConnectorStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_Reference(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "status": { + "kind": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", }, }, - "error": { + "apiVersion": { SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", }, }, - "files": { + "metadata": { SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.FileDetails"), - }, - }, - }, + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), }, }, - "folders": { + "spec": { SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Item"), - }, - }, - }, + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/apiclient/types.FileDetails", "github.com/gptscript-ai/otto/apiclient/types.Item"}, + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceSpec", "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } -func schema_storage_apis_ottogptscriptai_v1_OneDriveLinksList(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_ReferenceList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2678,7 +2936,7 @@ func schema_storage_apis_ottogptscriptai_v1_OneDriveLinksList(ref common.Referen Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OneDriveLinks"), + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Reference"), }, }, }, @@ -2689,11 +2947,11 @@ func schema_storage_apis_ottogptscriptai_v1_OneDriveLinksList(ref common.Referen }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.OneDriveLinks", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Reference", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } -func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_ReferenceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2711,27 +2969,13 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksSpec(ref common.Referen Format: "", }, }, - "sharedLinks": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, }, }, }, } } -func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_ReferenceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2750,18 +2994,20 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.Refer }, }, }, - "threadName": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "runName": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + } +} + +func schema_storage_apis_ottogptscriptai_v1_RemoteConnectorStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ "status": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, @@ -2774,7 +3020,7 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.Refer Format: "", }, }, - "folders": { + "files": { SchemaProps: spec.SchemaProps{ Type: []string{"object"}, AdditionalProperties: &spec.SchemaOrBool{ @@ -2782,53 +3028,27 @@ func schema_storage_apis_ottogptscriptai_v1_OnedriveLinksStatus(ref common.Refer Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/apiclient/types.Item"), + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.FileDetails"), }, }, }, }, }, - "lastReSyncStarted": { - SchemaProps: spec.SchemaProps{ - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/gptscript-ai/otto/apiclient/types.Item", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, - } -} - -func schema_storage_apis_ottogptscriptai_v1_Ref(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "ObjType": { - SchemaProps: spec.SchemaProps{ - Ref: ref("sigs.k8s.io/controller-runtime/pkg/client.Object"), - }, - }, - "Name": { + "state": { SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState"), }, }, }, - Required: []string{"ObjType", "Name"}, }, }, Dependencies: []string{ - "sigs.k8s.io/controller-runtime/pkg/client.Object"}, + "github.com/gptscript-ai/otto/apiclient/types.FileDetails", "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState"}, } } -func schema_storage_apis_ottogptscriptai_v1_Reference(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSource(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2857,24 +3077,24 @@ func schema_storage_apis_ottogptscriptai_v1_Reference(ref common.ReferenceCallba "spec": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceSpec"), + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceStatus"), + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceStatus"), }, }, }, }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceSpec", "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.ReferenceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceSpec", "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSourceStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } -func schema_storage_apis_ottogptscriptai_v1_ReferenceList(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2907,7 +3127,7 @@ func schema_storage_apis_ottogptscriptai_v1_ReferenceList(ref common.ReferenceCa Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Reference"), + Ref: ref("github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSource"), }, }, }, @@ -2918,11 +3138,11 @@ func schema_storage_apis_ottogptscriptai_v1_ReferenceList(ref common.ReferenceCa }, }, Dependencies: []string{ - "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.Reference", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/gptscript-ai/otto/pkg/storage/apis/otto.gptscript.ai/v1.RemoteKnowledgeSource", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } -func schema_storage_apis_ottogptscriptai_v1_ReferenceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2940,13 +3160,21 @@ func schema_storage_apis_ottogptscriptai_v1_ReferenceSpec(ref common.ReferenceCa Format: "", }, }, + "input": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceInput"), + }, + }, }, }, }, + Dependencies: []string{ + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceInput"}, } } -func schema_storage_apis_ottogptscriptai_v1_ReferenceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_storage_apis_ottogptscriptai_v1_RemoteKnowledgeSourceStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -2965,11 +3193,46 @@ func schema_storage_apis_ottogptscriptai_v1_ReferenceStatus(ref common.Reference }, }, }, + "threadName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "runName": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "error": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "state": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState"), + }, + }, + "lastReSyncStarted": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Time"), + }, + }, }, }, }, Dependencies: []string{ - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition"}, + "github.com/gptscript-ai/otto/apiclient/types.RemoteKnowledgeSourceState", "k8s.io/apimachinery/pkg/apis/meta/v1.Condition", "k8s.io/apimachinery/pkg/apis/meta/v1.Time"}, } } @@ -3521,7 +3784,7 @@ func schema_storage_apis_ottogptscriptai_v1_SyncUploadRequestSpec(ref common.Ref SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "uploadName": { + "remoteKnowledgeSourceName": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", diff --git a/pkg/storage/services/config.go b/pkg/storage/services/config.go index 5aa48db7..e1773508 100644 --- a/pkg/storage/services/config.go +++ b/pkg/storage/services/config.go @@ -18,6 +18,8 @@ type Config struct { DSN string `usage:"Database dsn in driver://connection_string format" default:"sqlite://file:otto.db?_journal=WAL&cache=shared&_busy_timeout=30000"` KnowledgeTool string `usage:"The knowledge tool to use" default:"github.com/gptscript-ai/knowledge" env:"KNOWLEDGE_TOOL"` OneDriveTool string `usage:"The OneDrive tool to use" default:"github.com/gptscript-ai/knowledge-onedrive-integration@otto" env:"ONEDRIVE_TOOL"` + NotionTool string `usage:"The Notion tool to use" default:"github.com/gptscript-ai/knowledge-notion-integration@otto" env:"NOTION_TOOL"` + WebsiteTool string `usage:"The website tool to use" default:"github.com/gptscript-ai/knowledge-website-integration@main" env:"WEBSITE_TOOL"` HelperModel string `usage:"The model used to generate names and descriptions" default:"gpt-4o-mini"` }