MCPcopy Create free account
hub / github.com/compozy/agh / resolveMemoryWorkspaceRef

Method resolveMemoryWorkspaceRef

internal/api/core/memory.go:1793–1820  ·  view source on GitHub ↗
(ctx context.Context, raw string)

Source from the content-addressed store, hash-verified

1791}
1792
1793func (h *BaseHandlers) resolveMemoryWorkspaceRef(ctx context.Context, raw string) (string, string, error) {
1794 trimmed := strings.TrimSpace(raw)
1795 if trimmed == "" {
1796 return "", "", NewMemoryValidationError(errors.New("workspace_id is required for workspace scope"))
1797 }
1798 if h.Workspaces != nil {
1799 resolved, err := h.Workspaces.Resolve(ctx, trimmed)
1800 if err == nil {
1801 workspaceID := strings.TrimSpace(resolved.WorkspaceID)
1802 if workspaceID == "" {
1803 return "", "", errors.New("memory: resolved workspace_id is empty")
1804 }
1805 return strings.TrimSpace(resolved.RootDir), workspaceID, nil
1806 }
1807 if !filepath.IsAbs(trimmed) {
1808 return "", "", err
1809 }
1810 }
1811 workspace, err := resolveMemoryWorkspace(trimmed)
1812 if err != nil {
1813 return "", "", err
1814 }
1815 identity, err := aghworkspace.EnsureIdentity(ctx, workspace)
1816 if err != nil {
1817 return "", "", fmt.Errorf("memory: resolve workspace identity: %w", err)
1818 }
1819 return workspace, identity.WorkspaceID, nil
1820}
1821
1822func memorySelectorFromQuery(c *gin.Context) memorySelector {
1823 workspaceID := firstNonEmptyString(c.Query("workspace_id"), c.Query("workspace"))

Callers 2

resolveMemorySelectorMethod · 0.95

Calls 3

NewMemoryValidationErrorFunction · 0.85
resolveMemoryWorkspaceFunction · 0.70
ResolveMethod · 0.65

Tested by

no test coverage detected